您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

36 行
1.1 KiB

using UnityEngine;
using UnityEngine.PostProcessing;
namespace UnityEditor.PostProcessing
{
[CustomPropertyDrawer(typeof(GetSetAttribute))]
sealed class GetSetDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
var attribute = (GetSetAttribute)base.attribute;
EditorGUI.BeginChangeCheck();
EditorGUI.PropertyField(position, property, label);
if (EditorGUI.EndChangeCheck())
{
attribute.dirty = true;
}
else if (attribute.dirty)
{
var parent = ReflectionUtils.GetParentObject(property.propertyPath, property.serializedObject.targetObject);
var type = parent.GetType();
var info = type.GetProperty(attribute.name);
if (info == null)
Debug.LogError("Invalid property name \"" + attribute.name + "\"");
else
info.SetValue(parent, fieldInfo.GetValue(parent), null);
attribute.dirty = false;
}
}
}
}