当前位置:网站首页>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()
边栏推荐
- Please answer the questions about database data transfer
- Can 7-day zero foundation prove HCIA? Huawei certification system learning path sharing
- 关于二进制无法精确表示小数
- Bus message bus
- Data of all class a scenic spots in China in 2022 (13604)
- 父组件传递给子组件:Props
- 【JDBC以及内部类的讲解】
- How can brand e-commerce grow against the trend? See the future here!
- Circulating tumor cells - here comes abnova's solution
- Config分布式配置中心
猜你喜欢
Pass parent component to child component: props
Can 7-day zero foundation prove HCIA? Huawei certification system learning path sharing
2022年全国所有A级景区数据(13604条)
[noi simulation] regional division (conclusion, structure)
LC interview question 02.07 Linked list intersection & lc142 Circular linked list II
jdbc数据库连接池使用问题
一文带你了解静态路由的特点、目的及配置基本功能示例
LVS+Keepalived(DR模式)学习笔记
. Net 5 fluentftp connection FTP failure problem: this operation is only allowed using a successfully authenticated context
How does an enterprise manage data? Share the experience summary of four aspects of data governance
随机推荐
The startup of MySQL installed in RPM mode of Linux system failed
Distributed ID solution
linux系统rpm方式安装的mysql启动失败
Master-slave replication principle of MySQL
ViewModelProvider. Of obsolete solution
Test of transform parameters of impdp
CompletableFuture使用详解
Basic introduction of JWT
SolidWorks GB Library (steel profile library, including aluminum profile, aluminum tube and other structures) installation and use tutorial (generating aluminum profile as an example)
Composition API 前提
Special behavior of main function in import statement
Common function detect_ image/predict
.net core 访问不常见的静态文件类型(MIME 类型)
基于JS的迷宫小游戏
请教一下,监听pgsql ,怎样可以监听多个schema和table
A slow SQL drags the whole system down
How can flinksql calculate the difference between a field before and after update when docking with CDC?
Maze games based on JS
From zero to one, I will teach you to build the "clip search by text" search service (2): 5 minutes to realize the prototype
非父子组件的通信