当前位置:网站首页>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()
边栏推荐
- Go straight to the 2022ecdc fluorite cloud Developer Conference: work with thousands of industries to accelerate intelligent upgrading
- 3428. Put apples
- [SOC FPGA] custom IP PWM breathing lamp
- c语言(结构体)定义一个User结构体,含以下字段:
- How to solve sqlstate[hy000]: General error: 1364 field 'xxxxx' doesn't have a default value error
- 牛客小白月赛52 E.分组求对数和(二分&容斥)
- MySQL的安装
- 项目实战 五 拟合直线 获得中线
- The difference between string constants and string objects when allocating memory
- Jmeter自带函数不够用?不如自己动手开发一个
猜你喜欢
LM small programmable controller software (based on CoDeSys) Note 23: conversion of relative coordinates of servo motor operation (stepping motor) to absolute coordinates
laravel 使用腾讯云 COS5全教程
You don't know the complete collection of recruitment slang of Internet companies
Handling hardfault in RT thread
JWT 认证
港科大&MSRA新研究:关于图像到图像转换,Fine-tuning is all you need
一段程序让你明白什么静态内部类,局部内部类,匿名内部类
学习笔记|数据小白使用DataEase制作数据大屏
MySQL卸载文档-Windows版
你不知道的互联网公司招聘黑话大全
随机推荐
直击2022ECDC萤石云开发者大会:携手千百行业加速智能升级
C language interview to write a function to find the first occurrence of substring m in string n.
[opencv] morphological filtering (2): open operation, morphological gradient, top hat, black hat
How to solve sqlstate[hy000]: General error: 1364 field 'xxxxx' doesn't have a default value error
【GNN】图解GNN: A gentle introduction(含视频)
「运维有小邓」符合GDPR的合规要求
Doctoral application | Professor Hong Liang, Academy of natural sciences, Shanghai Jiaotong University, enrolls doctoral students in deep learning
线性代数(一)
tkinter窗口选择pcd文件并显示点云(open3d)
How to find the literature of a foreign language journal?
Oracle迁移中关于大容量表使用数据泵(expdp、impdp)导出导入容易出现的问题和注意事项
怎样查找某个外文期刊的文献?
JMeter function assistant - random value, random string, fixed value random extraction
Handling hardfault in RT thread
软件测试的几个关键步骤,你需要知道
你不知道的互联网公司招聘黑话大全
蚂蚁庄园安全头盔 7.8蚂蚁庄园答案
软件测试到了35岁,真的就干不动了吗?
win系统下安装redis以及windows扩展方法
Qtthread, one of many methods of QT multithreading