59 lines
2.7 KiB
C#
59 lines
2.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Ichni.RhythmGame;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.Serialization;
|
|
|
|
namespace Ichni.Editor
|
|
{
|
|
public class DynamicUIAnimatedFloatUnit : DynamicUICompositeUnit
|
|
{
|
|
public TMP_InputField startTimeInputField;
|
|
public TMP_InputField endTimeInputField;
|
|
public TMP_InputField startValueInputField;
|
|
public TMP_InputField endValueInputField;
|
|
public TMP_Dropdown animationCurveTypeDropdown;
|
|
|
|
public override void SetUnit(CompositeParameterWindow window, object itemContent)
|
|
{
|
|
startTimeInputField.text = "0";
|
|
endTimeInputField.text = "0";
|
|
startValueInputField.text = "0";
|
|
endValueInputField.text = "0";
|
|
animationCurveTypeDropdown.value = 0;
|
|
compositeParameterWindow = window;
|
|
|
|
AnimatedFloat animatedFloat = (AnimatedFloat)itemContent;
|
|
startTimeInputField.text = animatedFloat.startTime.ToString();
|
|
endTimeInputField.text = animatedFloat.endTime.ToString();
|
|
startValueInputField.text = animatedFloat.startValue.ToString();
|
|
endValueInputField.text = animatedFloat.endValue.ToString();
|
|
animationCurveTypeDropdown.ClearOptions();
|
|
List<string> enumNameList = System.Enum.GetNames(typeof(AnimationCurveType)).ToList();
|
|
animationCurveTypeDropdown.AddOptions(enumNameList);
|
|
animationCurveTypeDropdown.value = (int)animatedFloat.animationCurveType;
|
|
|
|
|
|
startTimeInputField.onEndEdit.AddListener(_ => compositeParameterWindow.ApplyParameters());
|
|
endTimeInputField.onEndEdit.AddListener(_ => compositeParameterWindow.ApplyParameters());
|
|
startValueInputField.onEndEdit.AddListener(_ => compositeParameterWindow.ApplyParameters());
|
|
endValueInputField.onEndEdit.AddListener(_ => compositeParameterWindow.ApplyParameters());
|
|
animationCurveTypeDropdown.onValueChanged.AddListener(_ => compositeParameterWindow.ApplyParameters());
|
|
|
|
removeButton.onClick.AddListener(() =>
|
|
{
|
|
compositeParameterWindow.RemoveUnit(this);
|
|
compositeParameterWindow.ApplyParameters();
|
|
});
|
|
}
|
|
|
|
public AnimatedFloat GetValue()
|
|
{
|
|
return new AnimatedFloat(float.Parse(startTimeInputField.text), float.Parse(endTimeInputField.text),
|
|
float.Parse(startValueInputField.text), float.Parse(endValueInputField.text),
|
|
(AnimationCurveType)animationCurveTypeDropdown.value);
|
|
}
|
|
}
|
|
} |