This commit is contained in:
2025-03-30 16:06:57 +02:00
parent e62bd2aa6d
commit 623ba3f621
148 changed files with 2773 additions and 1441 deletions

View File

@@ -1,61 +0,0 @@
using RebootKit.Engine.Services.Console;
using SzafaKitEditor.VisualElements;
using UnityEditor;
using UnityEngine;
namespace SzafaKitEditor.PropertyDrawers {
[CustomPropertyDrawer(typeof(CVar))]
public class CVarPropertyDrawer : PropertyDrawer {
private bool _expand;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
SerializedProperty nameProperty = property.FindPropertyRelative("Name");
SerializedProperty descriptionProperty = property.FindPropertyRelative("Description");
SerializedProperty defaultValueProperty = property.FindPropertyRelative("DefaultValue");
SerializedProperty defaultValueKindProperty = defaultValueProperty.FindPropertyRelative("Kind");
SerializedProperty defaultValueNumberProperty = defaultValueProperty.FindPropertyRelative("NumberValue");
SerializedProperty defaultValueStringProperty = defaultValueProperty.FindPropertyRelative("StringValue");
EditorGUILayout.BeginHorizontal();
GUILayout.Label(label, EditorStyles.miniBoldLabel);
nameProperty.stringValue = EditorGUILayout.TextField(nameProperty.stringValue);
bool isNumber = defaultValueKindProperty.enumValueIndex == (int) CVarValueKind.Number;
string kindLabel = isNumber ? "N" : "S";
if (isNumber) {
GUI.color = Color.cyan;
} else {
GUI.color = Color.green;
}
if (GUILayout.Button(kindLabel, GUILayout.Width(32))) {
defaultValueKindProperty.enumValueIndex = isNumber ? (int) CVarValueKind.String : (int) CVarValueKind.Number;
}
GUI.color = Color.white;
if (isNumber) {
defaultValueNumberProperty.doubleValue = EditorGUILayout.DoubleField(defaultValueNumberProperty.doubleValue);
} else {
defaultValueStringProperty.stringValue = EditorGUILayout.TextField(defaultValueStringProperty.stringValue);
}
if (GUILayout.Button(_expand ? "H" : "S", GUILayout.MaxWidth(24))) {
_expand = !_expand;
}
EditorGUILayout.EndHorizontal();
if (_expand) {
EditorGUILayout.PropertyField(nameProperty, new GUIContent("Name"));
EditorGUILayout.PropertyField(descriptionProperty, new GUIContent("Description"));
EditorGUILayout.PropertyField(defaultValueKindProperty, new GUIContent("Value Kind"));
EditorGUILayout.PropertyField(defaultValueNumberProperty, new GUIContent("Number"));
EditorGUILayout.PropertyField(defaultValueStringProperty, new GUIContent("String"));
}
}
}
}

View File

@@ -0,0 +1,50 @@
using RebootKit.Engine.Services.Console;
using RebootKitEditor.Utils;
using UnityEditor;
using UnityEngine;
namespace RebootKitEditor.PropertyDrawers {
[CustomPropertyDrawer(typeof(CVar))]
public class CVarDrawer : PropertyDrawer {
bool m_Expand;
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
CVarSerializedProperties properties = CVarSerializedPropertiesFinder.Find(property);
EditorGUILayout.BeginHorizontal();
GUILayout.Label(label, EditorStyles.miniBoldLabel);
properties.name.stringValue = EditorGUILayout.TextField(properties.name.stringValue);
bool isNumber = properties.defaultValueKind.enumValueIndex == (int) CVarValueKind.Number;
string kindLabel = isNumber ? "N" : "S";
if (isNumber)
GUI.color = Color.cyan;
else
GUI.color = Color.green;
if (GUILayout.Button(kindLabel, GUILayout.Width(32))) properties.defaultValueKind.enumValueIndex = isNumber ? (int) CVarValueKind.String : (int) CVarValueKind.Number;
GUI.color = Color.white;
if (isNumber)
properties.defaultValueNumber.doubleValue = EditorGUILayout.DoubleField(properties.defaultValueNumber.doubleValue);
else
properties.defaultValueString.stringValue = EditorGUILayout.TextField(properties.defaultValueString.stringValue);
if (GUILayout.Button(m_Expand ? "H" : "S", GUILayout.MaxWidth(24))) m_Expand = !m_Expand;
EditorGUILayout.EndHorizontal();
if (m_Expand) {
EditorGUILayout.PropertyField(properties.name, new GUIContent("Name"));
EditorGUILayout.PropertyField(properties.description, new GUIContent("Description"));
EditorGUILayout.PropertyField(properties.defaultValueKind, new GUIContent("Value Kind"));
EditorGUILayout.PropertyField(properties.defaultValueNumber, new GUIContent("Number"));
EditorGUILayout.PropertyField(properties.defaultValueString, new GUIContent("String"));
}
}
}
}

View File

@@ -0,0 +1,23 @@
using RebootKit.Engine.Foundation;
using UnityEditor;
using UnityEngine;
namespace RebootKitEditor.PropertyDrawers {
[CustomPropertyDrawer(typeof(FloatRange))]
public class ValueRangeDrawer : PropertyDrawer {
const string k_minPropertyName = "min";
const string k_maxPropertyName = "max";
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
SerializedProperty minProperty = property.FindPropertyRelative(k_minPropertyName);
SerializedProperty maxProperty = property.FindPropertyRelative(k_maxPropertyName);
Vector2 minMax = EditorGUILayout.Vector2Field(label, new Vector2(minProperty.floatValue, maxProperty.floatValue));
if (minMax.x > minMax.y) minMax.y = minMax.x;
minProperty.floatValue = minMax.x;
maxProperty.floatValue = minMax.y;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0e847dcc2c154c10b7a3d00b9f6f49e5
timeCreated: 1742636936