refactor
This commit is contained in:
@@ -4,7 +4,7 @@ using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RebootKitEditor.PropertyDrawers {
|
||||
[CustomPropertyDrawer(typeof(CVar))]
|
||||
[CustomPropertyDrawer(typeof(ConfigVar))]
|
||||
public class CVarDrawer : PropertyDrawer {
|
||||
bool m_Expand;
|
||||
|
||||
|
||||
38
Editor/PropertyDrawers/ConstsPropertyDrawer.cs
Normal file
38
Editor/PropertyDrawers/ConstsPropertyDrawer.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using RebootKit.Engine.Foundation;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RebootKitEditor.PropertyDrawers {
|
||||
[CustomPropertyDrawer(typeof(ConstsProperty<>))]
|
||||
public class ConstsPropertyDrawer : PropertyDrawer {
|
||||
const string k_InlineValue = "m_InlineValue";
|
||||
const string k_Asset = "m_Asset";
|
||||
const string k_UseInlineValue = "m_UseInlineValue";
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
|
||||
SerializedProperty useInlineValue = property.FindPropertyRelative(k_UseInlineValue);
|
||||
SerializedProperty inlineValue = property.FindPropertyRelative(k_InlineValue);
|
||||
SerializedProperty asset = property.FindPropertyRelative(k_Asset);
|
||||
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
|
||||
GUILayout.BeginHorizontal();
|
||||
|
||||
EditorGUILayout.LabelField(label, EditorStyles.miniBoldLabel);
|
||||
|
||||
if (useInlineValue.boolValue) {
|
||||
EditorGUILayout.PropertyField(inlineValue, GUIContent.none);
|
||||
} else {
|
||||
EditorGUILayout.PropertyField(asset, GUIContent.none);
|
||||
}
|
||||
|
||||
if (GUILayout.Button(useInlineValue.boolValue ? "Inline" : "Asset", GUILayout.MaxWidth(100))) {
|
||||
useInlineValue.boolValue = !useInlineValue.boolValue;
|
||||
}
|
||||
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Editor/PropertyDrawers/ConstsPropertyDrawer.cs.meta
Normal file
3
Editor/PropertyDrawers/ConstsPropertyDrawer.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d7ed7ab023f349a4a4b50ee7a4029178
|
||||
timeCreated: 1743848631
|
||||
Reference in New Issue
Block a user