SamsonGame/Assets/Sources/unity-ui-extensions-master/Editor/ReadOnlyDrawer.cs

20 lines
535 B
C#
Raw Normal View History

2021-12-29 20:50:11 +03:00
/// Credit tanoshimi
/// Sourced from - https://forum.unity3d.com/threads/read-only-fields.68976/
///
using UnityEditor;
namespace UnityEngine.UI.Extensions
{
[CustomPropertyDrawer(typeof(ReadOnlyAttribute))]
public class ReadOnlyDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
GUI.enabled = false;
EditorGUI.PropertyField(position, property, label, true);
GUI.enabled = true;
}
}
}