1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
| #region 禁用面板 /// <summary> /// 禁用面板特性 /// </summary> public class DisplayOnly : PropertyAttribute {
} [CustomPropertyDrawer(typeof(DisplayOnly))] public class ReadOnlyDrawer : PropertyDrawer { public override float GetPropertyHeight(SerializedProperty property, GUIContent label) { return EditorGUI.GetPropertyHeight(property, label, true); } public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { GUI.enabled = false; EditorGUI.PropertyField(position, property, label, true); GUI.enabled = true; } } #endregion
|