当前位置:网站首页>Unity C# 函数笔记
Unity C# 函数笔记
2022-07-07 02:11:00 【小葱man】
寻找子对象的某个组件
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;
}
获取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;
}
获取继承某个父类的所有子类类型
TypeCache.TypeCollection types = TypeCache.GetTypesDerivedFrom<ScriptableRendererFeature>();
foreach (Type type in types)
{
Debug.Log(type);
}
OnValidate详解
/// Timeline 不会触发 OnValidate()
边栏推荐
- JWT 认证
- JVM in-depth
- How to solve sqlstate[hy000]: General error: 1364 field 'xxxxx' doesn't have a default value error
- Markdown displays pictures side by side
- Open the blue screen after VMware installation
- 高并发大流量秒杀方案思路
- 直击2022ECDC萤石云开发者大会:携手千百行业加速智能升级
- PostgreSQL database timescaledb function time_ bucket_ Gapfill() error resolution and license replacement
- 牛客小白月赛52 E.分组求对数和(二分&容斥)
- Crudini profile editing tool
猜你喜欢

Find duplicate email addresses

A program lets you understand what static inner classes, local inner classes, and anonymous inner classes are

高并发大流量秒杀方案思路

Leite smart home longhaiqi: from professional dimming to full house intelligence, 20 years of focus on professional achievements

项目实战 五 拟合直线 获得中线

请问如何查一篇外文文献的DOI号?

可极大提升编程思想与能力的书有哪些?

What are the classic database questions in the interview?

A very good JVM interview question article (74 questions and answers)

ETCD数据库源码分析——从raftNode的start函数说起
随机推荐
c面试 加密程序:由键盘输入明文,通过加密程序转换成密文并输出到屏幕上。
[Shell]常用shell命令及测试判断语句总结
Niuke Xiaobai monthly race 52 E. sum logarithms in groups (two points & inclusion and exclusion)
Shared memory for interprocess communication
PostgreSQL database timescaledb function time_ bucket_ Gapfill() error resolution and license replacement
You don't know the complete collection of recruitment slang of Internet companies
「运维有小邓」符合GDPR的合规要求
When we talk about immutable infrastructure, what are we talking about
Crudini profile editing tool
软件测试的几个关键步骤,你需要知道
Which foreign language periodicals are famous in geology?
How can I check the DOI number of a foreign document?
2022Android面试必备知识点,一文全面总结
谷歌 Chrome 浏览器发布 103.0.5060.114 补丁修复 0-day 漏洞
进程间通信之共享内存
Apache ab 压力测试
POI导出Excel:设置字体、颜色、行高自适应、列宽自适应、锁住单元格、合并单元格...
matlab / ENVI 主成分分析实现及结果分析
Haqi projection Black Horse posture, avec seulement six mois de forte pénétration du marché des projecteurs de 1000 yuans!
Postgresql源码(59)分析事务ID分配、溢出判断方法