当前位置:网站首页>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()
边栏推荐
- 品牌·咨询标准化
- LC interview question 02.07 Linked list intersection & lc142 Circular linked list II
- MySQL的主从复制原理
- Brand · consultation standardization
- Multidisciplinary integration
- Jesd204b clock network
- jdbc数据库连接池使用问题
- Network foundation - header, encapsulation and unpacking
- SolidWorks的GB库(钢型材库,包括铝型材、铝管等结构)安装及使用教程(生成铝型材为例)
- Tujia, muniao, meituan... Home stay summer war will start
猜你喜欢
Nesting and splitting of components
. Net core accesses uncommon static file types (MIME types)
MATLAB小技巧(29)多项式拟合 plotfit
Master-slave replication principle of MySQL
How to share the same storage among multiple kubernetes clusters
数据资产管理与数据安全国内外最新趋势
JWT的基础介绍
MySQL SQL的完整处理流程
2018年江苏省职业院校技能大赛高职组“信息安全管理与评估”赛项任务书第一阶段答案
How can brand e-commerce grow against the trend? See the future here!
随机推荐
LC interview question 02.07 Linked list intersection & lc142 Circular linked list II
linux系统rpm方式安装的mysql启动失败
AVL树的实现
Data of all class a scenic spots in China in 2022 (13604)
Mysql---- import and export & View & Index & execution plan
组件的嵌套和拆分
Circulating tumor cells - here comes abnova's solution
sqlserver多线程查询问题
[explanation of JDBC and internal classes]
From zero to one, I will teach you to build the "clip search by text" search service (2): 5 minutes to realize the prototype
$refs:组件中获取元素对象或者子组件实例:
Comment les entreprises gèrent - elles les données? Partager les leçons tirées des quatre aspects de la gouvernance des données
How can gyms improve their competitiveness?
一文带你了解静态路由的特点、目的及配置基本功能示例
Basic introduction of JWT
After the promotion, sales volume and flow are both. Is it really easy to relax?
A slow SQL drags the whole system down
toRefs API 与 toRef Api
. Net 5 fluentftp connection FTP failure problem: this operation is only allowed using a successfully authenticated context
Communication between non parent and child components