broken
This commit is contained in:
39
Editor/Utils/CVarSerializedPropertiesFinder.cs
Normal file
39
Editor/Utils/CVarSerializedPropertiesFinder.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user