Last active
March 4, 2024 05:45
-
-
Save Trissiklikk/17a4b45d772604cfe854a396fd5a0f86 to your computer and use it in GitHub Desktop.
Unity : ReadOnlyAttribute
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
using UnityEngine; | |
public class ReadOnlyAttribute : PropertyAttribute | |
{ | |
} |
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
using UnityEditor; | |
#if UNITY_EDITOR | |
[CustomPropertyDrawer(typeof(ReadOnlyAttribute))] | |
public sealed class ReadOnlyDrawer : PropertyDrawer | |
{ | |
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) | |
{ | |
GUI.enabled = false; | |
EditorGUI.PropertyField(position, property, label, true); | |
} | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment