当前位置:网站首页>Unity C# 函数笔记
Unity C# 函数笔记
2022-07-07 02:11:00 【小葱man】
寻找子对象的某个组件
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;
}
获取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;
}
获取继承某个父类的所有子类类型
TypeCache.TypeCollection types = TypeCache.GetTypesDerivedFrom<ScriptableRendererFeature>();
foreach (Type type in types)
{
Debug.Log(type);
}
OnValidate详解
/// Timeline 不会触发 OnValidate()
边栏推荐
- 隐马尔科夫模型(HMM)学习笔记
- 直击2022ECDC萤石云开发者大会:携手千百行业加速智能升级
- [SOC FPGA] peripheral PIO button lights up
- 微信小程序隐藏video标签的进度条组件
- 地质学类比较有名的外文期刊有哪些?
- 安装VMmare时候提示hyper-v / device defender 侧通道安全性
- 【解决】Final app status- UNDEFINED, exitCode- 16
- How to use wechat cloud hosting or cloud functions for cloud development of unapp development applet
- Developers don't miss it! Oar hacker marathon phase III chain oar track registration opens
- MySQL的安装
猜你喜欢

博士申请 | 上海交通大学自然科学研究院洪亮教授招收深度学习方向博士生

JWT 认证

Markdown 并排显示图片

Laravel uses Tencent cloud cos5 full tutorial

2022 Android interview essential knowledge points, a comprehensive summary

安装VMmare时候提示hyper-v / device defender 侧通道安全性

MySQL的安装

Several key steps of software testing, you need to know

Audio distortion analysis of DSP and DAC based on adau1452

Developers don't miss it! Oar hacker marathon phase III chain oar track registration opens
随机推荐
matlab / ENVI 主成分分析实现及结果分析
基本Dos命令
C面试24. (指针)定义一个含有20个元素的double型数组a
tkinter窗口选择pcd文件并显示点云(open3d)
3531. Huffman tree
HKUST & MsrA new research: on image to image conversion, fine tuning is all you need
dolphinscheduler3.x本地启动
软件测试的几个关键步骤,你需要知道
Calculation model FPS
2022Android面试必备知识点,一文全面总结
Matlab / envi principal component analysis implementation and result analysis
C interview 24 (pointer) define a double array with 20 elements a
Laravel uses Tencent cloud cos5 full tutorial
力扣62 不同路径(从矩阵左上到右下的所有路径数量) (动态规划)
ST表预处理时的数组证明
vim映射大K
LM small programmable controller software (based on CoDeSys) Note 23: conversion of relative coordinates of servo motor operation (stepping motor) to absolute coordinates
[solution] final app status- undefined, exitcode- 16
How to find the literature of a foreign language journal?
PostgreSQL database timescaledb function time_ bucket_ Gapfill() error resolution and license replacement