Added ReadOnlyOnPlayField Attribute.

This commit is contained in:
2022-07-08 21:16:41 +02:00
parent 518debbf1c
commit 31c51a1b2a
5 changed files with 39 additions and 1 deletions

View File

@ -0,0 +1,18 @@
using Runtime;
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;
}
}
}

View File

@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 9c45448d04584b318be7490a85ae4681
timeCreated: 1657132838