GUI: Fix plugin Enum options not working
This commit is contained in:
@@ -159,7 +159,9 @@ namespace Il2CppInspectorGUI
|
|||||||
else
|
else
|
||||||
options.Add(option.Name, (savedOption.Value, ((JsonElement) savedOption.Value).ValueKind) switch {
|
options.Add(option.Name, (savedOption.Value, ((JsonElement) savedOption.Value).ValueKind) switch {
|
||||||
(var v, JsonValueKind.String) => v.ToString(),
|
(var v, JsonValueKind.String) => v.ToString(),
|
||||||
(var v, JsonValueKind.Number) => Convert.ChangeType(v.ToString(), option.Value.GetType()),
|
(var v, JsonValueKind.Number) => option.Value.GetType().IsEnum?
|
||||||
|
Enum.TryParse(option.Value.GetType(), v.ToString(), out object e)? e : throw new InvalidCastException("Enum value removed")
|
||||||
|
: Convert.ChangeType(v.ToString(), option.Value.GetType()),
|
||||||
(var v, JsonValueKind.True) => true,
|
(var v, JsonValueKind.True) => true,
|
||||||
(var v, JsonValueKind.False) => false,
|
(var v, JsonValueKind.False) => false,
|
||||||
_ => throw new ArgumentException("Unsupported JSON type")
|
_ => throw new ArgumentException("Unsupported JSON type")
|
||||||
|
|||||||
Reference in New Issue
Block a user