当前位置:网站首页>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()
边栏推荐
- Communication of components
- 数据资产管理与数据安全国内外最新趋势
- Multidisciplinary integration
- Brand · consultation standardization
- Get the city according to IP
- IP address
- Jetpack compose is much more than a UI framework~
- Answer to the second stage of the assignment of "information security management and evaluation" of the higher vocational group of the 2018 Jiangsu Vocational College skills competition
- [Luogu p1971] rabbit and egg game (bipartite game)
- 2018年江苏省职业院校技能大赛高职组“信息安全管理与评估”赛项任务书
猜你喜欢

MATLAB小技巧(29)多项式拟合 plotfit

After the promotion, sales volume and flow are both. Is it really easy to relax?

Config分布式配置中心

2018 Jiangsu Vocational College skills competition vocational group "information security management and evaluation" competition assignment

Can 7-day zero foundation prove HCIA? Huawei certification system learning path sharing

DHCP路由器工作原理

Comment les entreprises gèrent - elles les données? Partager les leçons tirées des quatre aspects de la gouvernance des données

Paranoid unqualified company

MYSQL----导入导出&视图&索引&执行计划

Pass parent component to child component: props
随机推荐
Tool class: object to map hump to underline underline hump
品牌·咨询标准化
MySQL view bin log and recover data
Basic process of network transmission using tcp/ip four layer model
Jesd204b clock network
main函数在import语句中的特殊行为
. Net core accesses uncommon static file types (MIME types)
【mysqld】Can't create/write to file
Lvs+kept (DR mode) learning notes
一文带你了解静态路由的特点、目的及配置基本功能示例
CompletableFuture使用详解
[explanation of JDBC and internal classes]
Anr principle and Practice
MySql用户权限
Please tell me how to monitor multiple schemas and tables by listening to PgSQL
Matlab tips (29) polynomial fitting plotfit
Composition API 前提
Paranoid unqualified company
linux系统rpm方式安装的mysql启动失败
Select the product attribute pop-up box to pop up the animation effect from the bottom