当前位置:网站首页>Unity C function notes
Unity C function notes
2022-07-07 07:10:00 【Shallot man】
Find a component of a child object
public T FindTransform<T>(string name, Transform trans) where T : Component
{
foreach (T c in trans.GetComponentsInChildren<T>())
{
if (c.name == name)
{
return c;
}
}
return null;
}
obtain RenderFeature
private static readonly Dictionary<ScriptableRenderer, Dictionary<string, ScriptableRendererFeature>> s_renderFeatures = new Dictionary<ScriptableRenderer, Dictionary<string, ScriptableRendererFeature>>();
public static ScriptableRendererFeature GetRendererFeature(this ScriptableRenderer renderer, string name)
{
if (!s_renderFeatures.TryGetValue(renderer, out var innerFeatures))
{
var propertyInfo = renderer.GetType().GetProperty("rendererFeatures", BindingFlags.Instance | BindingFlags.NonPublic);
List<ScriptableRendererFeature> rendererFeatures = (List<ScriptableRendererFeature>)propertyInfo?.GetValue(renderer);
if (rendererFeatures == null)
{
s_renderFeatures[renderer] = null;
}
else
{
innerFeatures = new Dictionary<string, ScriptableRendererFeature>();
for (var i = 0; i < rendererFeatures.Count; i++)
{
var feature = rendererFeatures[i];
innerFeatures[feature.name] = feature;
}
s_renderFeatures[renderer] = innerFeatures;
}
}
if (innerFeatures != null)
{
innerFeatures.TryGetValue(name, out var result);
return result;
}
return null;
}
Get all subclass types that inherit a parent class
TypeCache.TypeCollection types = TypeCache.GetTypesDerivedFrom<ScriptableRendererFeature>();
foreach (Type type in types)
{
Debug.Log(type);
}
OnValidate Detailed explanation
/// Timeline Not trigger OnValidate()
边栏推荐
猜你喜欢

MATLAB小技巧(29)多项式拟合 plotfit

Mysql---- import and export & View & Index & execution plan

Leetcode t1165: log analysis

MOS管参数μCox得到的一种方法

Answer to the second stage of the assignment of "information security management and evaluation" of the higher vocational group of the 2018 Jiangsu Vocational College skills competition

7天零基础能考证HCIA吗?华为认证系统学习路线分享

组件的嵌套和拆分

. Net core accesses uncommon static file types (MIME types)

How can gyms improve their competitiveness?

Big coffee gathering | nextarch foundation cloud development meetup is coming
随机推荐
from . onnxruntime_ pybind11_ State Import * noqa ddddocr operation error
How to share the same storage among multiple kubernetes clusters
Multithreading and high concurrency (9) -- other synchronization components of AQS (semaphore, reentrantreadwritelock, exchanger)
Answer to the first stage of the assignment of "information security management and evaluation" of the higher vocational group of the 2018 Jiangsu Vocational College skills competition
Détailler le bleu dans les tâches de traduction automatique
组件的嵌套和拆分
from .onnxruntime_pybind11_state import * # noqa ddddocr运行报错
联合索引ABC的几种索引利用情况
FPGA course: application scenario of jesd204b (dry goods sharing)
$refs:组件中获取元素对象或者子组件实例:
关于数据库数据转移的问题,求各位解答下
DHCP路由器工作原理
MOS管参数μCox得到的一种方法
Four goals for the construction of intelligent safety risk management and control platform for hazardous chemical enterprises in Chemical Industry Park
Pass child component to parent component
Brand · consultation standardization
libcurl返回curlcode说明
Matlab tips (30) nonlinear fitting lsqcurefit
Under what circumstances should we consider sub database and sub table
LC 面试题 02.07. 链表相交 & LC142. 环形链表II