destroyed proj
This commit is contained in:
55
Packages/SzafaKit/Editor/Inspectors/CVarAssetInspector.cs
Normal file
55
Packages/SzafaKit/Editor/Inspectors/CVarAssetInspector.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user