Created
April 8, 2019 21:17
-
-
Save XakazukinX/5ddee72c45f149b110c84224b76e200d to your computer and use it in GitHub Desktop.
そのフィールドをインスペクタから変更できなくする自作属性
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if UNITY_EDITOR | |
using UnityEditor; | |
using UnityEngine; | |
namespace shigeno_EditorUtility | |
{ | |
public class NonEditableAttribute : PropertyAttribute | |
{ | |
} | |
[CustomPropertyDrawer(typeof(NonEditableAttribute))] | |
public class NonEditableDrawer : PropertyDrawer | |
{ | |
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) | |
{ | |
NonEditableAttribute NonEditable = (NonEditableAttribute) attribute; | |
EditorGUI.BeginDisabledGroup(true); | |
EditorGUI.PropertyField(position, property, label); | |
EditorGUI.EndDisabledGroup(); | |
} | |
} | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment