Files
RebootKit/Editor/Utils/CVarSerializedPropertiesFinder.cs
2025-07-30 05:51:39 +02:00

39 lines
1.8 KiB
C#
Executable File

using UnityEditor;
namespace RebootKit.Editor.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 CVarSerializedProperties();
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;
}
}
}