新Head
This commit is contained in:
@@ -74,7 +74,6 @@ namespace Ichni.Editor
|
||||
float.Parse(inputFieldBaseB.text), float.Parse(inputFieldBaseA.text));
|
||||
Ichni.Editor.Commands.CommandManager.ExecuteCommand(new Ichni.Editor.Commands.ChangeValueCommand(connectedBaseElement, parameterName, newValue));
|
||||
colorPreview.color = newValue;
|
||||
connectedBaseElement.Refresh();
|
||||
// 同步到HSV轮盘
|
||||
if (hsvDrawer != null)
|
||||
{
|
||||
|
||||
@@ -1,80 +1,123 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using DG.Tweening;
|
||||
using Ichni.RhythmGame;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Ichni.Editor
|
||||
{
|
||||
public abstract class DynamicUIElement : MonoBehaviour
|
||||
{
|
||||
Inspector Inspector => EditorManager.instance.uiManager.inspector;
|
||||
|
||||
public TMP_Text title;
|
||||
public CanvasGroup canvasGroup;
|
||||
public IBaseElement connectedBaseElement;
|
||||
|
||||
/// <summary>
|
||||
/// 参数名,通过反射获取饿修改对应变量的值
|
||||
/// </summary>
|
||||
public string parameterName;
|
||||
|
||||
public virtual void Initialize(IBaseElement baseElement, string title, string parameterName)
|
||||
{
|
||||
if (canvasGroup == null) canvasGroup = gameObject.AddComponent<CanvasGroup>();
|
||||
this.connectedBaseElement = baseElement;
|
||||
this.parameterName = parameterName;
|
||||
if (title != string.Empty)
|
||||
{
|
||||
this.title.text = title;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.title.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public DynamicUIElement Mark(string mark = "Default", IHaveInspection inspection = null)
|
||||
{
|
||||
inspection ??= Inspector;
|
||||
if (mark == "Default")
|
||||
{
|
||||
mark = title.text;
|
||||
}
|
||||
|
||||
inspection.MarkedElements.TryAdd(mark, this);
|
||||
return this;
|
||||
}
|
||||
public abstract DynamicUIElement AddListenerFunction(UnityAction action);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
public interface IHaveTagLink
|
||||
{
|
||||
public IBaseElement connectedBaseElement { get; set; }
|
||||
|
||||
// public void GetApply()
|
||||
// {
|
||||
// EditorManager.instance.projectInformation.tagManager.SyncTagedElement(connectedBaseElement);
|
||||
// }
|
||||
}
|
||||
}
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using DG.Tweening;
|
||||
using Ichni.RhythmGame;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Ichni.Editor
|
||||
{
|
||||
public abstract class DynamicUIElement : MonoBehaviour
|
||||
{
|
||||
Inspector Inspector => EditorManager.instance.uiManager.inspector;
|
||||
|
||||
public TMP_Text title;
|
||||
public CanvasGroup canvasGroup;
|
||||
public IBaseElement connectedBaseElement;
|
||||
|
||||
/// <summary>
|
||||
/// 参数名,通过反射获取饿修改对应变量的值
|
||||
/// </summary>
|
||||
public string parameterName;
|
||||
|
||||
/// <summary>
|
||||
/// 缓存的 LayoutElement,用于 InspectorBuilder 的 Flexible 布局模式。
|
||||
/// </summary>
|
||||
private LayoutElement _layoutElement;
|
||||
|
||||
public virtual void Initialize(IBaseElement baseElement, string title, string parameterName)
|
||||
{
|
||||
if (canvasGroup == null) canvasGroup = gameObject.AddComponent<CanvasGroup>();
|
||||
this.connectedBaseElement = baseElement;
|
||||
this.parameterName = parameterName;
|
||||
if (title != string.Empty)
|
||||
{
|
||||
this.title.text = title;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.title.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public DynamicUIElement Mark(string mark = "Default", IHaveInspection inspection = null)
|
||||
{
|
||||
inspection ??= Inspector;
|
||||
if (mark == "Default")
|
||||
{
|
||||
mark = title.text;
|
||||
}
|
||||
|
||||
inspection.MarkedElements.TryAdd(mark, this);
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置此元素在 Flexible 布局中的尺寸。
|
||||
/// 由 InspectorBuilder 或 Drawer 在元素创建后调用。
|
||||
/// </summary>
|
||||
public void SetLayoutSize(float preferredWidth, float preferredHeight)
|
||||
{
|
||||
if (_layoutElement == null)
|
||||
_layoutElement = GetComponent<LayoutElement>();
|
||||
if (_layoutElement == null)
|
||||
_layoutElement = gameObject.AddComponent<LayoutElement>();
|
||||
|
||||
_layoutElement.preferredWidth = preferredWidth;
|
||||
_layoutElement.preferredHeight = preferredHeight;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 禁用指定 Selectable 组件的导航(统一处理,避免各 Generate 方法重复编写)。
|
||||
/// </summary>
|
||||
public static void DisableNavigation(Selectable selectable)
|
||||
{
|
||||
if (selectable != null)
|
||||
selectable.navigation = new Navigation { mode = Navigation.Mode.None };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量禁用多个 Selectable 的导航。
|
||||
/// </summary>
|
||||
public static void DisableNavigation(params Selectable[] selectables)
|
||||
{
|
||||
var nav = new Navigation { mode = Navigation.Mode.None };
|
||||
foreach (var s in selectables)
|
||||
{
|
||||
if (s != null)
|
||||
s.navigation = nav;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract DynamicUIElement AddListenerFunction(UnityAction action);
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
public interface IHaveTagLink
|
||||
{
|
||||
public IBaseElement connectedBaseElement { get; set; }
|
||||
|
||||
// public void GetApply()
|
||||
// {
|
||||
// EditorManager.instance.projectInformation.tagManager.SyncTagedElement(connectedBaseElement);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,6 @@ namespace Ichni.Editor
|
||||
Ichni.Editor.Commands.CommandManager.ExecuteCommand(new Ichni.Editor.Commands.ChangeValueCommand(connectedBaseElement, colorParameterName, emissionColor));
|
||||
|
||||
colorPreview.color = emissionColor;
|
||||
connectedBaseElement.Refresh();
|
||||
}
|
||||
|
||||
public void SliderChange(float value)
|
||||
|
||||
@@ -49,7 +49,6 @@ namespace Ichni.Editor
|
||||
private void ApplyParameters(int value)
|
||||
{
|
||||
Ichni.Editor.Commands.CommandManager.ExecuteCommand(new Ichni.Editor.Commands.ChangeValueCommand(connectedBaseElement, parameterName, value));
|
||||
connectedBaseElement.Refresh();
|
||||
}
|
||||
|
||||
public override DynamicUIElement AddListenerFunction(UnityAction action)
|
||||
|
||||
@@ -113,7 +113,6 @@ namespace Ichni.Editor
|
||||
{
|
||||
Ichni.Editor.Commands.CommandManager.ExecuteCommand(new Ichni.Editor.Commands.ChangeValueCommand(connectedBaseElement, parameterName, value));
|
||||
}
|
||||
connectedBaseElement.Refresh();
|
||||
}
|
||||
|
||||
public override DynamicUIElement AddListenerFunction(UnityAction action)
|
||||
|
||||
@@ -156,7 +156,6 @@ namespace Ichni.Editor
|
||||
}
|
||||
Ichni.Editor.Commands.CommandManager.ExecuteCommand(
|
||||
new Ichni.Editor.Commands.ChangeValueCommand(connectedBaseElement, parameterName, convertedValue));
|
||||
connectedBaseElement.Refresh();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -76,7 +76,6 @@ namespace Ichni.Editor
|
||||
private void ApplyParameters(string value)
|
||||
{
|
||||
Ichni.Editor.Commands.CommandManager.ExecuteCommand(new Ichni.Editor.Commands.ChangeValueCommand(connectedBaseElement, parameterName, value));
|
||||
connectedBaseElement.Refresh();
|
||||
}
|
||||
|
||||
public override DynamicUIElement AddListenerFunction(UnityAction action)
|
||||
|
||||
@@ -53,7 +53,6 @@ namespace Ichni.Editor
|
||||
private void ApplyParameters(bool value)
|
||||
{
|
||||
Ichni.Editor.Commands.CommandManager.ExecuteCommand(new Ichni.Editor.Commands.ChangeValueCommand(connectedBaseElement, parameterName, value));
|
||||
connectedBaseElement.Refresh();
|
||||
}
|
||||
|
||||
public override DynamicUIElement AddListenerFunction(UnityAction action)
|
||||
|
||||
@@ -116,7 +116,6 @@ namespace Ichni.Editor
|
||||
{
|
||||
Vector2 newValue = new Vector2(float.Parse(inputFieldX.text), float.Parse(inputFieldY.text));
|
||||
Ichni.Editor.Commands.CommandManager.ExecuteCommand(new Ichni.Editor.Commands.ChangeValueCommand(connectedBaseElement, parameterName, newValue));
|
||||
connectedBaseElement.Refresh();
|
||||
}
|
||||
|
||||
public override DynamicUIElement AddListenerFunction(UnityAction action)
|
||||
|
||||
@@ -135,7 +135,6 @@ namespace Ichni.Editor
|
||||
{
|
||||
Vector3 newValue = new Vector3(float.Parse(inputFieldX.text), float.Parse(inputFieldY.text), float.Parse(inputFieldZ.text));
|
||||
Ichni.Editor.Commands.CommandManager.ExecuteCommand(new Ichni.Editor.Commands.ChangeValueCommand(connectedBaseElement, parameterName, newValue));
|
||||
connectedBaseElement.Refresh();
|
||||
}
|
||||
|
||||
public override DynamicUIElement AddListenerFunction(UnityAction action)
|
||||
|
||||
Reference in New Issue
Block a user