您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
28 行
840 B
28 行
840 B
using System.Reflection;
|
|
|
|
namespace UnityEditor.Recorder
|
|
{
|
|
class TargetedPropertyDrawer<T> : PropertyDrawer where T : class
|
|
{
|
|
protected T target;
|
|
|
|
protected virtual void Initialize(SerializedProperty prop)
|
|
{
|
|
if (target == null)
|
|
{
|
|
var path = prop.propertyPath.Split('.');
|
|
object obj = prop.serializedObject.targetObject;
|
|
|
|
foreach (var pathNode in path)
|
|
obj = GetSerializedField(obj, pathNode).GetValue(obj);
|
|
|
|
target = obj as T;
|
|
}
|
|
}
|
|
|
|
static FieldInfo GetSerializedField(object target, string pathNode)
|
|
{
|
|
return target.GetType().GetField(pathNode, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
|
|
}
|
|
}
|
|
}
|