From f24a081fcef3192fe80b7dca8591a60dbd770ea8 Mon Sep 17 00:00:00 2001 From: Jenny Crowe Date: Sun, 20 Feb 2022 06:31:55 -0700 Subject: [PATCH] Editor: General enum property support. Hex input field functionality for color picker. --- Assets/Plugins/Color picker/ColorPreview.cs | 5 +++++ Assets/Scenes/Editor.unity | 14 +++++++++++++- .../Scripts/Games/RhythmTweezers/RhythmTweezers.cs | 6 ++++++ Assets/Scripts/Games/Spaceball/Spaceball.cs | 6 ++++++ .../EventSelector/EventParameterManager.cs | 2 +- .../EventSelector/EventPropertyPrefab.cs | 11 ++++++----- Assets/Scripts/Minigames.cs | 6 +++--- 7 files changed, 40 insertions(+), 10 deletions(-) diff --git a/Assets/Plugins/Color picker/ColorPreview.cs b/Assets/Plugins/Color picker/ColorPreview.cs index 00757ca79..85362b1a9 100644 --- a/Assets/Plugins/Color picker/ColorPreview.cs +++ b/Assets/Plugins/Color picker/ColorPreview.cs @@ -40,4 +40,9 @@ public class ColorPreview : MonoBehaviour if (colorPicker != null) colorPicker.onColorChanged -= OnColorChanged; } + + public void SetColorFromTMP() + { + SetColorFromHex(hex.text); + } } \ No newline at end of file diff --git a/Assets/Scenes/Editor.unity b/Assets/Scenes/Editor.unity index e6ef1998e..1c20c9df7 100644 --- a/Assets/Scenes/Editor.unity +++ b/Assets/Scenes/Editor.unity @@ -3925,7 +3925,19 @@ MonoBehaviour: m_CharacterLimit: 0 m_OnEndEdit: m_PersistentCalls: - m_Calls: [] + m_Calls: + - m_Target: {fileID: 1535224921} + m_TargetAssemblyTypeName: ColorPreview, Assembly-CSharp-firstpass + m_MethodName: SetColorFromTMP + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 m_OnSubmit: m_PersistentCalls: m_Calls: [] diff --git a/Assets/Scripts/Games/RhythmTweezers/RhythmTweezers.cs b/Assets/Scripts/Games/RhythmTweezers/RhythmTweezers.cs index 4e19c9735..0ddfd480e 100644 --- a/Assets/Scripts/Games/RhythmTweezers/RhythmTweezers.cs +++ b/Assets/Scripts/Games/RhythmTweezers/RhythmTweezers.cs @@ -12,6 +12,12 @@ namespace RhythmHeavenMania.Games.RhythmTweezers // use PlayerActionObject for the actual tweezers but this isn't playable rn so IDC public class RhythmTweezers : Minigame { + public enum VegetableType + { + Onion, + Potato + } + [Header("References")] public Transform VegetableHolder; public SpriteRenderer Vegetable; diff --git a/Assets/Scripts/Games/Spaceball/Spaceball.cs b/Assets/Scripts/Games/Spaceball/Spaceball.cs index 677ba0d54..7f30ac3b6 100644 --- a/Assets/Scripts/Games/Spaceball/Spaceball.cs +++ b/Assets/Scripts/Games/Spaceball/Spaceball.cs @@ -8,6 +8,12 @@ namespace RhythmHeavenMania.Games.Spaceball { public class Spaceball : Minigame { + public enum CostumeType { + Standard, + Bunny, + SphereHead + } + public GameObject Ball; public GameObject BallsHolder; diff --git a/Assets/Scripts/LevelEditor/EventSelector/EventParameterManager.cs b/Assets/Scripts/LevelEditor/EventSelector/EventParameterManager.cs index 24b992370..c828eacba 100644 --- a/Assets/Scripts/LevelEditor/EventSelector/EventParameterManager.cs +++ b/Assets/Scripts/LevelEditor/EventSelector/EventParameterManager.cs @@ -106,7 +106,7 @@ namespace RhythmHeavenMania.Editor { prefab = FloatP; } - else if (objType == typeof(RhythmHeavenMania.Util.EasingFunction.Ease)) + else if (objType.IsEnum) { prefab = DropdownP; } diff --git a/Assets/Scripts/LevelEditor/EventSelector/EventPropertyPrefab.cs b/Assets/Scripts/LevelEditor/EventSelector/EventPropertyPrefab.cs index 3ab26e0d7..5f9231b14 100644 --- a/Assets/Scripts/LevelEditor/EventSelector/EventPropertyPrefab.cs +++ b/Assets/Scripts/LevelEditor/EventSelector/EventPropertyPrefab.cs @@ -2,6 +2,7 @@ using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; +using System; using TMPro; using Starpelly; @@ -84,12 +85,12 @@ namespace RhythmHeavenMania.Editor parameterManager.entity[propertyName] = slider.value; }); } - else if (objType == typeof(EasingFunction.Ease)) + else if (objType.IsEnum) { List dropDownData = new List(); - for (int i = 0; i < System.Enum.GetValues(typeof(EasingFunction.Ease)).Length; i++) + for (int i = 0; i < System.Enum.GetValues(objType).Length; i++) { - string name = System.Enum.GetNames(typeof(EasingFunction.Ease))[i]; + string name = System.Enum.GetNames(objType)[i]; TMP_Dropdown.OptionData optionData = new TMP_Dropdown.OptionData(); optionData.text = name; @@ -97,11 +98,11 @@ namespace RhythmHeavenMania.Editor dropDownData.Add(optionData); } dropdown.AddOptions(dropDownData); - dropdown.value = ((int)(EasingFunction.Ease)parameterManager.entity[propertyName]); + dropdown.value = ((int)Enum.Parse(objType, parameterManager.entity[propertyName].ToString())); dropdown.onValueChanged.AddListener(delegate { - parameterManager.entity[propertyName] = (EasingFunction.Ease)dropdown.value; + parameterManager.entity[propertyName] = Enum.ToObject(objType, dropdown.value); }); } else if (objType == typeof(Color)) diff --git a/Assets/Scripts/Minigames.cs b/Assets/Scripts/Minigames.cs index 2af195069..2bb316da2 100644 --- a/Assets/Scripts/Minigames.cs +++ b/Assets/Scripts/Minigames.cs @@ -150,7 +150,7 @@ namespace RhythmHeavenMania new GameAction("shootHigh", delegate { Spaceball.instance.Shoot(eventCaller.currentEntity.beat, true, eventCaller.currentEntity.type); }, 3), new GameAction("costume", delegate { Spaceball.instance.Costume(eventCaller.currentEntity.type); }, 1f, false, new List() { - new Param("type", new EntityTypes.Integer(0, 2), "Type") + new Param("type", Spaceball.CostumeType.Standard, "Type") } ), new GameAction("alien", delegate { Spaceball.instance.alien.Show(eventCaller.currentEntity.beat); } ), new GameAction("camera", delegate { Spaceball.instance.OverrideCurrentZoom(); }, 4, true, new List() @@ -205,13 +205,13 @@ namespace RhythmHeavenMania new GameAction("long hair", delegate { RhythmTweezers.instance.SpawnLongHair(eventCaller.currentEntity.beat); }, 0.5f), new GameAction("next vegetable", delegate { var e = eventCaller.currentEntity; RhythmTweezers.instance.NextVegetable(e.beat, e.type, e.colorA, e.colorB); }, 0.5f, false, new List() { - new Param("type", new EntityTypes.Integer(0, 1), "Type"), + new Param("type", RhythmTweezers.VegetableType.Onion, "Type"), new Param("colorA", RhythmTweezers.defaultOnionColor, "Onion Color"), new Param("colorB", RhythmTweezers.defaultPotatoColor, "Potato Color") } ), new GameAction("change vegetable", delegate { var e = eventCaller.currentEntity; RhythmTweezers.instance.ChangeVegetableImmediate(e.type, e.colorA, e.colorB); }, 0.5f, false, new List() { - new Param("type", new EntityTypes.Integer(0, 1), "Type"), + new Param("type", RhythmTweezers.VegetableType.Onion, "Type"), new Param("colorA", RhythmTweezers.defaultOnionColor, "Onion Color"), new Param("colorB", RhythmTweezers.defaultPotatoColor, "Potato Color") } ),