Utils/Editor/ReadOnlyOnPlayFieldDrawer.cs
2022-07-08 21:17:48 +02:00

17 lines
516 B
C#

using UnityEditor;
using UnityEngine;
namespace Utils
{
[CustomPropertyDrawer(typeof(ReadOnlyOnPlayFieldAttribute))]
public class ReadOnlyOnPlayFieldDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
var state = Application.isPlaying;
if (state) GUI.enabled = false;
EditorGUI.PropertyField(position, property, label, true);
if (state) GUI.enabled = true;
}
}
}