From 207c2ace3f78ffde731a1b7fdf75ed3d99a837fc Mon Sep 17 00:00:00 2001 From: minenice55 Date: Fri, 5 Jan 2024 21:34:35 -0500 Subject: [PATCH] fix control style dropdowns --- .../PropertyPrefabs/EnumChartPropertyPrefab.cs | 17 ++++++----------- .../Tabs/ChartInfoProperties.cs | 11 ++++++++--- Assets/Scripts/Minigames.cs | 2 ++ 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Assets/Scripts/LevelEditor/RemixPropertiesDialog/PropertyPrefabs/EnumChartPropertyPrefab.cs b/Assets/Scripts/LevelEditor/RemixPropertiesDialog/PropertyPrefabs/EnumChartPropertyPrefab.cs index 9a66e55c0..89faf4049 100644 --- a/Assets/Scripts/LevelEditor/RemixPropertiesDialog/PropertyPrefabs/EnumChartPropertyPrefab.cs +++ b/Assets/Scripts/LevelEditor/RemixPropertiesDialog/PropertyPrefabs/EnumChartPropertyPrefab.cs @@ -1,14 +1,9 @@ +using UnityEngine; +using System; using System.Collections; using System.Collections.Generic; -using UnityEngine; -using UnityEngine.UI; -using System; using System.Linq; using TMPro; -using Starpelly; - -using HeavenStudio.Util; -using HeavenStudio.Editor; namespace HeavenStudio.Editor { @@ -22,9 +17,9 @@ namespace HeavenStudio.Editor { InitProperties(diag, propertyName, caption); - var enumType = type.GetType(); - var enumVals = Enum.GetValues(enumType); - var enumNames = Enum.GetNames(enumType).ToList(); + Type enumType = type.GetType(); + Array enumVals = Enum.GetValues(enumType); + List enumNames = Enum.GetNames(enumType).ToList(); // Can we assume non-holey enum? // If we can we can simplify to dropdown.value = (int) parameterManager.chart[propertyName] @@ -38,7 +33,7 @@ namespace HeavenStudio.Editor dropdown.value = selected; dropdown.onValueChanged.AddListener(_ => - parameterManager.chart[propertyName] = (int) enumVals.GetValue(dropdown.value) + parameterManager.chart[propertyName] = Enum.ToObject(enumType, (int) enumVals.GetValue(dropdown.value)) ); } diff --git a/Assets/Scripts/LevelEditor/RemixPropertiesDialog/Tabs/ChartInfoProperties.cs b/Assets/Scripts/LevelEditor/RemixPropertiesDialog/Tabs/ChartInfoProperties.cs index 05409f746..79ebc71b3 100644 --- a/Assets/Scripts/LevelEditor/RemixPropertiesDialog/Tabs/ChartInfoProperties.cs +++ b/Assets/Scripts/LevelEditor/RemixPropertiesDialog/Tabs/ChartInfoProperties.cs @@ -25,10 +25,15 @@ namespace HeavenStudio.Editor public void AddParam(RemixPropertiesDialog diag, string propertyName, object type, string caption, bool isReadOnly = false, string tooltip = "") { + if (!Minigames.propertiesModel.ContainsKey(propertyName)) + { + Debug.LogError("Property " + propertyName + " does not exist!"); + return; + } GameObject prefab = diag.IntegerP; GameObject input; - var objType = type.GetType(); + var objType = Minigames.propertiesModel[propertyName].GetType(); if (objType == typeof(EntityTypes.Integer)) { @@ -83,13 +88,13 @@ namespace HeavenStudio.Editor property.SetProperties(diag, propertyName, type, caption); break; default: - Debug.LogError("Can't make property interface of type: " + type.GetType()); + Debug.LogError("Can't make property interface of type: " + objType); return; } } else { - Debug.LogError("Can't make property interface of type: " + type.GetType()); + Debug.LogError("Can't make property interface of type: " + objType); return; } } diff --git a/Assets/Scripts/Minigames.cs b/Assets/Scripts/Minigames.cs index 7baf6cb21..13ce88788 100644 --- a/Assets/Scripts/Minigames.cs +++ b/Assets/Scripts/Minigames.cs @@ -325,6 +325,8 @@ namespace HeavenStudio { if (data.properties[prop.Key].GetType() == typeof(string)) data.properties[prop.Key] = Enum.Parse(mType, (string)data.properties[prop.Key]); + else + data.properties[prop.Key] = Enum.ToObject(mType, data.properties[prop.Key]); } // convert all JObjects to their respective types else if (data.properties[prop.Key].GetType() == typeof(Newtonsoft.Json.Linq.JObject))