Editor: General enum property support. Hex input field functionality for color picker.

This commit is contained in:
Jenny Crowe
2022-02-20 06:31:55 -07:00
parent ed738d8b0e
commit f24a081fce
7 changed files with 40 additions and 10 deletions

View File

@ -106,7 +106,7 @@ namespace RhythmHeavenMania.Editor
{
prefab = FloatP;
}
else if (objType == typeof(RhythmHeavenMania.Util.EasingFunction.Ease))
else if (objType.IsEnum)
{
prefab = DropdownP;
}

View File

@ -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<TMP_Dropdown.OptionData> dropDownData = new List<TMP_Dropdown.OptionData>();
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))