Added ReadOnlyOnPlayField Attribute.
This commit is contained in:
18
Editor/ReadOnlyOnPlayFieldDrawer.cs
Normal file
18
Editor/ReadOnlyOnPlayFieldDrawer.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
3
Editor/ReadOnlyOnPlayFieldDrawer.cs.meta
Normal file
3
Editor/ReadOnlyOnPlayFieldDrawer.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c45448d04584b318be7490a85ae4681
|
||||
timeCreated: 1657132838
|
Reference in New Issue
Block a user