当前位置:网站首页>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()
边栏推荐
- Stack Title: nesting depth of valid parentheses
- Master-slave replication principle of MySQL
- OOM(内存溢出)造成原因及解决方案
- The startup of MySQL installed in RPM mode of Linux system failed
- MYSQL----导入导出&视图&索引&执行计划
- from . onnxruntime_ pybind11_ State Import * noqa ddddocr operation error
- Explain Bleu in machine translation task in detail
- Complete process of MySQL SQL
- toRefs API 与 toRef Api
- Config distributed configuration center
猜你喜欢

子组件传递给父组件

$parent(获取父组件) 和 $root(获取根组件)

Bus message bus

带你刷(牛客网)C语言百题(第一天)

$refs: get the element object or sub component instance in the component:

Please answer the questions about database data transfer

MySQL SQL的完整处理流程

Abnova membrane protein lipoprotein technology and category display

LC 面试题 02.07. 链表相交 & LC142. 环形链表II

How can clothing stores make profits?
随机推荐
Data of all class a scenic spots in China in 2022 (13604)
MOS管参数μCox得到的一种方法
SolidWorks GB Library (steel profile library, including aluminum profile, aluminum tube and other structures) installation and use tutorial (generating aluminum profile as an example)
SolidWorks的GB库(钢型材库,包括铝型材、铝管等结构)安装及使用教程(生成铝型材为例)
Graduation design game mall
关于数据库数据转移的问题,求各位解答下
多线程与高并发(9)——AQS其他同步组件(Semaphore、ReentrantReadWriteLock、Exchanger)
MySql用户权限
2018年江苏省职业院校技能大赛高职组“信息安全管理与评估”赛项任务书第二阶段答案
Big coffee gathering | nextarch foundation cloud development meetup is coming
Master-slave replication principle of MySQL
Prime partner of Huawei machine test questions
Lvs+kept (DR mode) learning notes
MATLAB小技巧(29)多项式拟合 plotfit
工具类:对象转map 驼峰转下划线 下划线转驼峰
弹性布局(二)
FPGA course: application scenario of jesd204b (dry goods sharing)
Matlab tips (30) nonlinear fitting lsqcurefit
栈题目:有效括号的嵌套深度
Libcurl returns curlcode description