Inspector Secondary Window & QuickCopy
inspector的二级界面,主要用于工具制作。 重新制作了Track的QuickCopy功能
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
namespace Ichni.Editor
|
||||
{
|
||||
public class DynamicUIParameterInputField : DynamicUIElement
|
||||
{
|
||||
public TMP_InputField inputField;
|
||||
|
||||
public override void Initialize(IBaseElement baseElement, string title, string parameterName)
|
||||
{
|
||||
base.Initialize(baseElement, title, parameterName);
|
||||
inputField.text = connectedBaseElement.GetType().GetField(parameterName).GetValue(connectedBaseElement).ToString(); //获取对应变量的值
|
||||
|
||||
inputField.onEndEdit.AddListener(ApplyParameters);
|
||||
}
|
||||
|
||||
private void ApplyParameters(string text)
|
||||
{
|
||||
Type type = connectedBaseElement.GetType().GetField(parameterName).FieldType;
|
||||
if (type == typeof(int))
|
||||
{
|
||||
connectedBaseElement.GetType().GetField(parameterName).SetValue(connectedBaseElement, int.Parse(text));
|
||||
}
|
||||
else if (type == typeof(float))
|
||||
{
|
||||
connectedBaseElement.GetType().GetField(parameterName).SetValue(connectedBaseElement, float.Parse(text));
|
||||
}
|
||||
else if (type == typeof(string))
|
||||
{
|
||||
connectedBaseElement.GetType().GetField(parameterName).SetValue(connectedBaseElement, text);
|
||||
}
|
||||
connectedBaseElement.Refresh();
|
||||
}
|
||||
|
||||
public void AddListenerFunction(UnityAction<string> action)
|
||||
{
|
||||
inputField.onEndEdit.AddListener(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user