当前位置:网站首页>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()
边栏推荐
猜你喜欢
Use of completable future
Answer to the first stage of the assignment of "information security management and evaluation" of the higher vocational group of the 2018 Jiangsu Vocational College skills competition
Take you to brush (niuke.com) C language hundred questions (the first day)
关于数据库数据转移的问题,求各位解答下
组件的嵌套和拆分
How to model and simulate the target robot [mathematical / control significance]
Matlab tips (29) polynomial fitting plotfit
2022年全国所有A级景区数据(13604条)
transform-origin属性详解
freeswitch拨打分机号源代码跟踪
随机推荐
Special behavior of main function in import statement
Composition API 前提
AVL树的实现
Bus message bus
How to model and simulate the target robot [mathematical / control significance]
transform-origin属性详解
Precise space-time travel flow regulation system - ultra-high precision positioning system based on UWB
Pass child component to parent component
请教一下,监听pgsql ,怎样可以监听多个schema和table
Mysql---- import and export & View & Index & execution plan
Abnova membrane protein lipoprotein technology and category display
Select the product attribute pop-up box to pop up the animation effect from the bottom
LC interview question 02.07 Linked list intersection & lc142 Circular linked list II
from . onnxruntime_ pybind11_ State Import * noqa ddddocr operation error
$parent(获取父组件) 和 $root(获取根组件)
Get the city according to IP
Basic introduction of JWT
DHCP路由器工作原理
Answer to the first stage of the assignment of "information security management and evaluation" of the higher vocational group of the 2018 Jiangsu Vocational College skills competition
一文带你了解静态路由的特点、目的及配置基本功能示例