1
Fork 0
mirror of https://github.com/Steffo99/gravity-fusion.git synced 2024-11-22 16:24:20 +00:00
gravity-fusion/Assets/Editor/BeforeStartAttributeDrawer.cs

21 lines
786 B
C#
Raw Permalink Normal View History

2019-10-06 17:40:54 +00:00
//From https://answers.unity.com/questions/442342/how-to-make-public-variable-read-only-during-run-t.html
2019-10-04 19:14:29 +00:00
using UnityEngine;
using UnityEditor;
[CustomPropertyDrawer(typeof(BeforeStart))]
public class BeforeStartAttributeDrawer : PropertyDrawer
{
// Necessary since some properties tend to collapse smaller than their content
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
return EditorGUI.GetPropertyHeight(property, label, true);
}
// Draw a disabled property field
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
GUI.enabled = !Application.isPlaying;
EditorGUI.PropertyField(position, property, label, true);
GUI.enabled = true;
}
2019-10-06 17:40:54 +00:00
}