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,55 +0,0 @@
using RebootKit.Engine.Services.Console;
using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace RebootKitEditor.Inspectors {
[CustomEditor(typeof(CVarAsset))]
public class CVarAssetInspector : Editor {
public override VisualElement CreateInspectorGUI() {
SerializedProperty cvarProperty = serializedObject.FindProperty("_cvar");
CVarSerializedProperties properties = CVarSerializedPropertiesFinder.Find(cvarProperty);
VisualElement container = new();
container.Add(new PropertyField(properties.Flags));
container.Add(new PropertyField(properties.Name));
PropertyField descriptionField = new PropertyField(properties.Description);
container.Add(descriptionField);
container.Add(new PropertyField(properties.ValueKind));
container.Add(new PropertyField(properties.ValueNumber));
container.Add(new PropertyField(properties.ValueString));
return container;
}
}
public struct CVarSerializedProperties {
public SerializedProperty Flags;
public SerializedProperty Name;
public SerializedProperty Description;
public SerializedProperty ValueKind;
public SerializedProperty ValueNumber;
public SerializedProperty ValueString;
}
public static class CVarSerializedPropertiesFinder {
public static CVarSerializedProperties Find(SerializedProperty cvar) {
CVarSerializedProperties properties = new();
properties.Flags = cvar.FindPropertyRelative("Flags");
properties.Name = cvar.FindPropertyRelative("Name");
properties.Description = cvar.FindPropertyRelative("Description");
SerializedProperty value = cvar.FindPropertyRelative("DefaultValue");
if (value != null) {
properties.ValueKind = value.FindPropertyRelative("Kind");
properties.ValueNumber = value.FindPropertyRelative("NumberValue");
properties.ValueString = value.FindPropertyRelative("StringValue");
}
return properties;
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 43a78b204a01438ea8e99757046c213d
timeCreated: 1741641043

View File

@@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: e148f21299f99ad4fa76c50598092230
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,23 +0,0 @@
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
namespace SzafaKitEditor.Oracle {
public class OracleWindow : EditorWindow {
[SerializeField]
private VisualTreeAsset m_VisualTreeAsset = default;
[MenuItem("Szafa/Oracle")]
public static void ShowWindow() {
OracleWindow wnd = GetWindow<OracleWindow>();
wnd.titleContent = new GUIContent("OracleWindow");
}
public void CreateGUI() {
VisualElement root = rootVisualElement;
VisualElement labelFromUXML = m_VisualTreeAsset.Instantiate();
root.Add(labelFromUXML);
}
}
}

View File

@@ -1,13 +0,0 @@
fileFormatVersion: 2
guid: e2bd75a497487ee49a0a51cc223c552d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences:
- m_VisualTreeAsset: {fileID: 9197481963319205126, guid: 852055ed179f6f546b9f0ff34d97f4fb,
type: 3}
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,5 +0,0 @@
.custom-label {
font-size: 20px;
-unity-font-style: bold;
color: rgb(68, 138, 255);
}

View File

@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: 56459608f8e71f140b0933d6689a0846
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}
disableValidation: 0

View File

@@ -1,10 +0,0 @@
<engine:UXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:engine="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<Style src="project://database/Packages/com.szafastudio.szafakit/Editor/Oracle/OracleWindow.uss?fileID=7433441132597879392&amp;guid=56459608f8e71f140b0933d6689a0846&amp;type=3#OracleWindow" />
<engine:TabView>
<engine:Tab label="General">
<engine:Label text="Welcome to my szafa" style="-unity-font-style: bold; font-size: 48px;" />
</engine:Tab>
<engine:Tab label="Startup" />
<engine:Tab label="Build" />
</engine:TabView>
</engine:UXML>

View File

@@ -1,10 +0,0 @@
fileFormatVersion: 2
guid: 852055ed179f6f546b9f0ff34d97f4fb
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}

View File

@@ -1,26 +0,0 @@
using RebootKit.Engine;
using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.UIElements;
namespace SzafaKitEditor.Oracle {
[CustomEditor(typeof(RR))]
public class SzKEngineEditor : Editor {
private EngineConfigAsset _engineConfigAsset;
public override VisualElement CreateInspectorGUI() {
VisualElement inspector = new VisualElement();
_engineConfigAsset = Resources.Load<EngineConfigAsset>(RConsts.EngineConfigResourcesPath);
if (_engineConfigAsset == null) {
inspector.Add(new Label($"Couldn't load engine config from resources: {RConsts.EngineConfigResourcesPath}"));
return inspector;
}
inspector.Add(new Label("Config:"));
InspectorElement.FillDefaultInspector(inspector, new SerializedObject(_engineConfigAsset), this);
return inspector;
}
}
}

View File

@@ -1,3 +0,0 @@
fileFormatVersion: 2
guid: 6f2d98247b7f40e88946af3956c54a5e
timeCreated: 1741081201

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

View File

@@ -1,18 +1,18 @@
{
"name": "SzafaKitEditor",
"rootNamespace": "RebootKitEditor",
"references": [
"GUID:284059c7949783646b281a1b815580e6"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
"name": "SzafaKitEditor",
"rootNamespace": "RebootKitEditor",
"references": [
"GUID:284059c7949783646b281a1b815580e6"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

3
Editor/Utils.meta Normal file
View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1201995b5ab64155bcd531cf153892e5
timeCreated: 1742499685

View File

@@ -0,0 +1,39 @@
using UnityEditor;
namespace RebootKitEditor.Utils {
public struct CVarSerializedProperties {
public SerializedProperty flags;
public SerializedProperty name;
public SerializedProperty description;
public SerializedProperty defaultValueKind;
public SerializedProperty defaultValueNumber;
public SerializedProperty defaultValueString;
}
public static class CVarSerializedPropertiesFinder {
const string k_CVarFlagsProperty = "name";
const string k_CVarNameProperty = "name";
const string k_CVarDescriptionProperty = "description";
const string k_CVarDefaultValueProperty = "defaultValue";
const string k_CVarDefaultValueKindProperty = "kind";
const string k_CVarDefaultValueNumberValueProperty = "numberValue";
const string k_CVarDefaultValueStringValueProperty = "stringValue";
public static CVarSerializedProperties Find(SerializedProperty cvar) {
CVarSerializedProperties properties = new();
properties.flags = cvar.FindPropertyRelative(k_CVarFlagsProperty);
properties.name = cvar.FindPropertyRelative(k_CVarNameProperty);
properties.description = cvar.FindPropertyRelative(k_CVarDescriptionProperty);
SerializedProperty value = cvar.FindPropertyRelative(k_CVarDefaultValueProperty);
if (value != null) {
properties.defaultValueKind = value.FindPropertyRelative(k_CVarDefaultValueKindProperty);
properties.defaultValueNumber = value.FindPropertyRelative(k_CVarDefaultValueNumberValueProperty);
properties.defaultValueString = value.FindPropertyRelative(k_CVarDefaultValueStringValueProperty);
}
return properties;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b244cfd75ae64aeebe0299f28ec08267
timeCreated: 1742499696

View File

@@ -5,16 +5,16 @@ using UnityEngine.UIElements;
namespace SzafaKitEditor.VisualElements {
public class CVarPropertyField : VisualElement {
private SerializedProperty _cvarProperty;
private SerializedProperty _nameProperty;
private SerializedProperty _defaultValueProperty;
private SerializedProperty _defaultValueKindProperty;
private SerializedProperty _defaultValueNumberProperty;
private SerializedProperty _defaultValueStringProperty;
readonly SerializedProperty _cvarProperty;
readonly SerializedProperty _defaultValueKindProperty;
readonly SerializedProperty _defaultValueNumberProperty;
readonly SerializedProperty _defaultValueProperty;
readonly SerializedProperty _defaultValueStringProperty;
private VisualElement _details;
VisualElement _details;
private bool _expand;
bool _expand;
readonly SerializedProperty _nameProperty;
public CVarPropertyField(SerializedProperty cvarProperty) {
_cvarProperty = cvarProperty;
@@ -28,14 +28,14 @@ namespace SzafaKitEditor.VisualElements {
CreateDetailsBox();
}
private void CreateInlineField() {
VisualElement box = new VisualElement() {
void CreateInlineField() {
VisualElement box = new() {
style = {
height = 48
}
};
Label nameLabel = new Label("NAME") {
Label nameLabel = new("NAME") {
style = {
unityFontStyleAndWeight = FontStyle.Bold,
backgroundColor = new Color(0.1f, 0.1f, 0.1f, 1.0f)
@@ -47,29 +47,29 @@ namespace SzafaKitEditor.VisualElements {
text = "...",
style = {
width = new StyleLength(new Length(64.0f, LengthUnit.Pixel)),
height = new StyleLength(new Length(64.0f, LengthUnit.Pixel)),
height = new StyleLength(new Length(64.0f, LengthUnit.Pixel))
}
};
box.Add(button);
Add(box);
}
private void ToggleDetails() {
void ToggleDetails() {
_expand = !_expand;
_details.visible = _expand;
_details.style.display = DisplayStyle.None;
}
private void CreateDetailsBox() {
void CreateDetailsBox() {
PropertyField nameField = new(_nameProperty);
PropertyField defaultValueKindField = new(_defaultValueKindProperty);
PropertyField numberField = new(_defaultValueNumberProperty);
PropertyField stringField = new(_defaultValueStringProperty);
_details = new VisualElement() {
_details = new VisualElement {
style = {
backgroundColor = new Color(0.1f, 0.1f, 0.1f, 1.0f),
backgroundColor = new Color(0.1f, 0.1f, 0.1f, 1.0f)
}
};
_details.Add(nameField);