Files
trail-into-darkness/Packages/com.jovian.inspector/Editor/Attributes/InitializationFieldAttribute.cs
2026-03-29 18:59:24 +02:00

34 lines
809 B
C#

using UnityEngine;
namespace InspectorToolkit
{
/// <summary>
/// Field will be Read-Only in Playmode
/// </summary>
public class InitializationFieldAttribute : PropertyAttribute
{
}
}
#if UNITY_EDITOR
namespace InspectorToolkit.Internal
{
using UnityEditor;
[CustomPropertyDrawer(typeof(InitializationFieldAttribute))]
public class InitializationFieldAttributeDrawer : PropertyDrawer
{
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return EditorGUI.GetPropertyHeight(property, label, true);
}
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
if (Application.isPlaying) GUI.enabled = false;
EditorGUI.PropertyField(position, property, label, true);
GUI.enabled = true;
}
}
}
#endif