28 lines
796 B
C#
28 lines
796 B
C#
namespace UnityEngine
|
|
{
|
|
#if UNITY_EDITOR
|
|
/// <summary>
|
|
/// 设置属性只读
|
|
/// </summary>
|
|
public class DisplayOnly : PropertyAttribute
|
|
{
|
|
|
|
}
|
|
[UnityEditor.CustomPropertyDrawer(typeof(DisplayOnly))]
|
|
public class ReadOnlyDrawer : UnityEditor.PropertyDrawer
|
|
{
|
|
public override float GetPropertyHeight(UnityEditor.SerializedProperty property, GUIContent label)
|
|
{
|
|
return UnityEditor.EditorGUI.GetPropertyHeight(property, label, true);
|
|
}
|
|
public override void OnGUI(Rect position, UnityEditor.SerializedProperty property, GUIContent label)
|
|
{
|
|
GUI.enabled = false;
|
|
UnityEditor.EditorGUI.PropertyField(position, property, label, true);
|
|
GUI.enabled = true;
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
|