自动更新型DUI扩展,将Time变量挪出TImeline UI,Effect效果容器修缮,移除Note的transform模块,Scene Camera优化
This commit is contained in:
@@ -18,11 +18,6 @@ namespace Ichni.Editor
|
||||
/// 参数名,通过反射获取饿修改对应变量的值
|
||||
/// </summary>
|
||||
public string parameterName;
|
||||
|
||||
/// <summary>
|
||||
/// 是否始终更新,如果子类可能用到此变量,则在子类中写Update即可(注意,如果最后仅有Text用到此变量,直接移动它到Text即可)
|
||||
/// </summary>
|
||||
public bool isAlwaysUpdated;
|
||||
|
||||
public virtual void Initialize(IBaseElement baseElement, string title, string parameterName)
|
||||
{
|
||||
@@ -54,4 +49,21 @@ namespace Ichni.Editor
|
||||
|
||||
//public abstract void ApplyParameters();
|
||||
}
|
||||
|
||||
public interface IHaveAutoUpdate
|
||||
{
|
||||
public bool isAutoUpdate { get; set; }
|
||||
public bool isReceiving { get; set; }
|
||||
public void SetAutoUpdate(bool enable);
|
||||
|
||||
public void UpdateContent()
|
||||
{
|
||||
if(isAutoUpdate && isReceiving)
|
||||
{
|
||||
ApplyContent();
|
||||
}
|
||||
}
|
||||
|
||||
public void ApplyContent();
|
||||
}
|
||||
}
|
||||
@@ -8,18 +8,51 @@ using UnityEngine.Events;
|
||||
|
||||
namespace Ichni.Editor
|
||||
{
|
||||
public class DynamicUIParameterInputField : DynamicUIElement
|
||||
public class DynamicUIInputField : DynamicUIElement, IHaveAutoUpdate
|
||||
{
|
||||
public TMP_InputField inputField;
|
||||
|
||||
public bool isAutoUpdate { get; set; }
|
||||
public bool isReceiving { get; set; }
|
||||
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);
|
||||
if (parameterName != string.Empty)
|
||||
{
|
||||
ApplyContent();
|
||||
inputField.onEndEdit.AddListener(ApplyParameters);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void Update()
|
||||
{
|
||||
(this as IHaveAutoUpdate).UpdateContent();
|
||||
}
|
||||
|
||||
public void SetDefaultValue(string text)
|
||||
{
|
||||
inputField.text = text;
|
||||
}
|
||||
|
||||
public T GetValue<T>()
|
||||
{
|
||||
return (T)Convert.ChangeType(inputField.text, typeof(T));
|
||||
}
|
||||
|
||||
public void SetAutoUpdate(bool enable)
|
||||
{
|
||||
isAutoUpdate = enable;
|
||||
isReceiving = true;
|
||||
|
||||
inputField.onSelect.AddListener(_ => isReceiving = false);
|
||||
inputField.onDeselect.AddListener(_ => isReceiving = true);
|
||||
}
|
||||
|
||||
public void ApplyContent()
|
||||
{
|
||||
inputField.text = connectedBaseElement.GetType().GetField(parameterName).GetValue(connectedBaseElement).ToString(); //获取对应变量的值
|
||||
}
|
||||
|
||||
private void ApplyParameters(string text)
|
||||
{
|
||||
Type type = connectedBaseElement.GetType().GetField(parameterName).FieldType;
|
||||
@@ -7,22 +7,32 @@ using UnityEngine;
|
||||
|
||||
namespace Ichni.Editor
|
||||
{
|
||||
public class DynamicUIParameterText : DynamicUIElement
|
||||
public class DynamicUIParameterText : DynamicUIElement, IHaveAutoUpdate
|
||||
{
|
||||
public TMP_Text text;
|
||||
public bool isAutoUpdate { get; set; }
|
||||
public bool isReceiving { get; set; }
|
||||
|
||||
public override void Initialize(IBaseElement baseElement, string title, string parameterName)
|
||||
{
|
||||
base.Initialize(baseElement, title, parameterName);
|
||||
text.text = connectedBaseElement.GetType().GetField(parameterName).GetValue(connectedBaseElement).ToString();
|
||||
ApplyContent();
|
||||
}
|
||||
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (isAlwaysUpdated)
|
||||
{
|
||||
text.text = connectedBaseElement.GetType().GetField(parameterName).GetValue(connectedBaseElement).ToString();
|
||||
}
|
||||
(this as IHaveAutoUpdate).UpdateContent();
|
||||
}
|
||||
|
||||
public void SetAutoUpdate(bool enable)
|
||||
{
|
||||
isAutoUpdate = enable;
|
||||
isReceiving = true;
|
||||
}
|
||||
|
||||
public void ApplyContent()
|
||||
{
|
||||
text.text = connectedBaseElement.GetType().GetField(parameterName).GetValue(connectedBaseElement).ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Ichni.RhythmGame;
|
||||
@@ -10,27 +11,66 @@ using UnityEngine.UIElements.Experimental;
|
||||
|
||||
namespace Ichni.Editor
|
||||
{
|
||||
public class DynamicUIVector3InputField : DynamicUIElement
|
||||
public class DynamicUIVector3InputField : DynamicUIElement, IHaveAutoUpdate
|
||||
{
|
||||
public TMP_InputField inputFieldX;
|
||||
public TMP_InputField inputFieldY;
|
||||
public TMP_InputField inputFieldZ;
|
||||
public bool isAutoUpdate { get; set; }
|
||||
public bool isReceiving { get; set; }
|
||||
|
||||
public override void Initialize(IBaseElement baseElement, string title, string parameterName)
|
||||
{
|
||||
base.Initialize(baseElement, title, parameterName);
|
||||
if (parameterName != string.Empty)
|
||||
{
|
||||
ApplyContent();
|
||||
|
||||
inputFieldX.onEndEdit.AddListener(_ => ApplyParameters());
|
||||
inputFieldY.onEndEdit.AddListener(_ => ApplyParameters());
|
||||
inputFieldZ.onEndEdit.AddListener(_ => ApplyParameters());
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
(this as IHaveAutoUpdate).UpdateContent();
|
||||
}
|
||||
|
||||
public void SetDefaultValue(Vector3 value)
|
||||
{
|
||||
inputFieldX.text = value.x.ToString();
|
||||
inputFieldY.text = value.y.ToString();
|
||||
inputFieldZ.text = value.z.ToString();
|
||||
}
|
||||
|
||||
public Vector3 GetValue()
|
||||
{
|
||||
return new Vector3(float.Parse(inputFieldX.text), float.Parse(inputFieldY.text), float.Parse(inputFieldZ.text));
|
||||
}
|
||||
|
||||
public void SetAutoUpdate(bool enable)
|
||||
{
|
||||
isAutoUpdate = enable;
|
||||
isReceiving = true;
|
||||
|
||||
inputFieldX.onSelect.AddListener(_ => isReceiving = false);
|
||||
inputFieldY.onSelect.AddListener(_ => isReceiving = false);
|
||||
inputFieldZ.onSelect.AddListener(_ => isReceiving = false);
|
||||
|
||||
inputFieldX.onDeselect.AddListener(_ => isReceiving = true);
|
||||
inputFieldY.onDeselect.AddListener(_ => isReceiving = true);
|
||||
inputFieldZ.onDeselect.AddListener(_ => isReceiving = true);
|
||||
}
|
||||
|
||||
public void ApplyContent()
|
||||
{
|
||||
Vector3 pos = (Vector3)connectedBaseElement.GetType().GetField(parameterName).GetValue(connectedBaseElement); //获取对应变量的值
|
||||
inputFieldX.text = pos.x.ToString();
|
||||
inputFieldY.text = pos.y.ToString();
|
||||
inputFieldZ.text = pos.z.ToString();
|
||||
|
||||
inputFieldX.onEndEdit.AddListener(_ => ApplyParameters());
|
||||
inputFieldY.onEndEdit.AddListener(_ => ApplyParameters());
|
||||
inputFieldZ.onEndEdit.AddListener(_ => ApplyParameters());
|
||||
}
|
||||
public override void DeviverSet(int i){
|
||||
//我什么也不做
|
||||
}
|
||||
|
||||
private void ApplyParameters()
|
||||
{
|
||||
Vector3 newValue = new Vector3(float.Parse(inputFieldX.text), float.Parse(inputFieldY.text), float.Parse(inputFieldZ.text));
|
||||
@@ -44,5 +84,9 @@ namespace Ichni.Editor
|
||||
inputFieldY.onEndEdit.AddListener(_ => action());
|
||||
inputFieldZ.onEndEdit.AddListener(_ => action());
|
||||
}
|
||||
|
||||
public override void DeviverSet(int i){
|
||||
//我什么也不做
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user