当前位置:网站首页>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()
边栏推荐
- Comment les entreprises gèrent - elles les données? Partager les leçons tirées des quatre aspects de la gouvernance des données
- Test of transform parameters of impdp
- How DHCP router works
- freeswitch拨打分机号源代码跟踪
- Exception of DB2 getting table information: caused by: com ibm. db2.jcc. am. SqlException: [jcc][t4][1065][12306][4.25.13]
- Pass parent component to child component: props
- Special behavior of main function in import statement
- Under what circumstances should we consider sub database and sub table
- MySQL user permissions
- Common function detect_ image/predict
猜你喜欢
随机推荐
7天零基础能考证HCIA吗?华为认证系统学习路线分享
关于数据库数据转移的问题,求各位解答下
Nesting and splitting of components
Can 7-day zero foundation prove HCIA? Huawei certification system learning path sharing
非父子组件的通信
A slow SQL drags the whole system down
品牌·咨询标准化
Four goals for the construction of intelligent safety risk management and control platform for hazardous chemical enterprises in Chemical Industry Park
什么情况下考虑分库分表
2022年全国所有A级景区数据(13604条)
一文带你了解静态路由的特点、目的及配置基本功能示例
libcurl返回curlcode说明
组件的通信
异步组件和Suspense(真实开发中)
Paranoid unqualified company
[noi simulation] regional division (conclusion, structure)
请教一个问题,flink oracle cdc,读取一个没有更新操作的表,隔十几秒就重复读取全量数据
How DHCP router works
栈题目:有效括号的嵌套深度
詳解機器翻譯任務中的BLEU