当前位置:网站首页>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()
边栏推荐
- MySQL installation
- c面试 加密程序:由键盘输入明文,通过加密程序转换成密文并输出到屏幕上。
- vim映射大K
- Shared memory for interprocess communication
- Haqi projection Black Horse posture, avec seulement six mois de forte pénétration du marché des projecteurs de 1000 yuans!
- Qt多线程的多种方法之一 QThread
- Leite smart home longhaiqi: from professional dimming to full house intelligence, 20 years of focus on professional achievements
- C language interview to write a function to find the first public string in two strings
- How to keep accounts of expenses in life
- JVM 全面深入
猜你喜欢

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

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

ICML 2022 | 探索语言模型的最佳架构和训练方法

BindingException 异常(报错)处理

The difference between string constants and string objects when allocating memory

你不知道的互联网公司招聘黑话大全

3531. Huffman tree

dolphinscheduler3.x本地启动

【从零开始】win10系统部署Yolov5详细过程(CPU,无GPU)

Several key steps of software testing, you need to know
随机推荐
Doctoral application | Professor Hong Liang, Academy of natural sciences, Shanghai Jiaotong University, enrolls doctoral students in deep learning
牛客小白月赛52 E.分组求对数和(二分&容斥)
Install mongodb database
Overview of FlexRay communication protocol
Common problems of caching in high concurrency scenarios
[SOC FPGA] custom IP PWM breathing lamp
win系统下安装redis以及windows扩展方法
Open the blue screen after VMware installation
How to keep accounts of expenses in life
How to use wechat cloud hosting or cloud functions for cloud development of unapp development applet
How to solve sqlstate[hy000]: General error: 1364 field 'xxxxx' doesn't have a default value error
软件测试的几个关键步骤,你需要知道
Laravel uses Tencent cloud cos5 full tutorial
dolphinscheduler3.x本地启动
Qt多线程的多种方法之一 QThread
When we talk about immutable infrastructure, what are we talking about
JVM 全面深入
拼多多败诉:“砍价免费拿”侵犯知情权但不构成欺诈,被判赔400元
360 Zhiyu released 7.0 new products to create an exclusive "unified digital workspace" for the party, government and army, and central and state-owned enterprises
C language sorting (to be updated)