Added ReadOnlyOnPlayField Attribute.

This commit is contained in:
Alexander Filippov 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

View File

@ -0,0 +1,6 @@
using UnityEngine;
namespace Utils
{
public class ReadOnlyOnPlayFieldAttribute : PropertyAttribute { }
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 751004c02d9af6559a8f5c714cf58568
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,6 +1,6 @@
{
"name": "ru.shazbot.utils",
"version": "4.0.0",
"version": "4.1.0",
"displayName": "Utils",
"description": "Utility useful for almost any project.",
"licensesUrl": "https://git.shazbot.ru/Utils.git/tree/LICENSE.md",