重构inspector!

This commit is contained in:
SoulliesOfficial
2025-04-14 17:49:47 -04:00
parent bbca8b43fe
commit 11543b4997
81 changed files with 1037 additions and 903 deletions

View File

@@ -64,7 +64,7 @@ namespace Ichni.Editor
ApplyParameters();
}
public override void AddListenerFunction(UnityAction action)
public override DynamicUIElement AddListenerFunction(UnityAction action)
{
inputFieldBaseR.onEndEdit.AddListener(_ => action());
inputFieldBaseG.onEndEdit.AddListener(_ => action());
@@ -75,6 +75,8 @@ namespace Ichni.Editor
sliderG.onValueChanged.AddListener(_ => action());
sliderB.onValueChanged.AddListener(_ => action());
sliderA.onValueChanged.AddListener(_ => action());
return this;
}
}
}

View File

@@ -13,10 +13,9 @@ namespace Ichni.Editor
public Button button;
public TMP_Text buttonText;
public void SetText(string buttonText, bool showTitle)
public void SetText(string buttonText)
{
this.buttonText.text = buttonText;
if(!showTitle) title.gameObject.SetActive(false);
}
public void ApplyFunction(UnityAction function)
@@ -28,7 +27,7 @@ namespace Ichni.Editor
}
}
public override void AddListenerFunction(UnityAction action)
public override DynamicUIElement AddListenerFunction(UnityAction action)
{
throw new System.NotImplementedException();
}

View File

@@ -11,6 +11,8 @@ namespace Ichni.Editor
{
public abstract class DynamicUIElement : MonoBehaviour
{
Inspector Inspector => EditorManager.instance.uiManager.inspector;
public TMP_Text title;
public CanvasGroup canvasGroup;
public IBaseElement connectedBaseElement;
@@ -34,28 +36,19 @@ namespace Ichni.Editor
}
}
public void Mark(IHaveInspection inspection, string mark)
public DynamicUIElement Mark(string mark = "Default", IHaveInspection inspection = null)
{
inspection.MarkedElements.Add(mark, this);
inspection ??= Inspector;
if (mark == "Default")
{
mark = title.text;
}
inspection.MarkedElements.TryAdd(mark, this);
return this;
}
public abstract void AddListenerFunction(UnityAction action);
public virtual void DeviverSet(int DeviveNum){
float o=2f/DeviveNum;//因为所有的单UI都是根据2栏来的
Button[] childb=GetComponentsInChildren<Button>();
TMP_Text[] childt=GetComponentsInChildren<TMP_Text>();
foreach (var i in childb){
RectTransform rectTransform = i.GetComponent<RectTransform>();
rectTransform.sizeDelta=new Vector2(rectTransform.sizeDelta.x*o,rectTransform.sizeDelta.y);
}
foreach (var i in childt){
RectTransform rectTransform = i.GetComponent<RectTransform>();
rectTransform.sizeDelta=new Vector2(rectTransform.sizeDelta.x*o,rectTransform.sizeDelta.y);
}
}
//public abstract void ApplyParameters();
public abstract DynamicUIElement AddListenerFunction(UnityAction action);
}
public interface IHaveAutoUpdate

View File

@@ -80,7 +80,7 @@ namespace Ichni.Editor
ApplyParameters();
}
public override void AddListenerFunction(UnityAction action)
public override DynamicUIElement AddListenerFunction(UnityAction action)
{
toggleEnableEmission.onValueChanged.AddListener(_ => action());
@@ -92,6 +92,8 @@ namespace Ichni.Editor
sliderR.onValueChanged.AddListener(_ => action());
sliderG.onValueChanged.AddListener(_ => action());
sliderB.onValueChanged.AddListener(_ => action());
return this;
}
}
}

View File

@@ -33,9 +33,10 @@ namespace Ichni.Editor
connectedBaseElement.Refresh();
}
public override void AddListenerFunction(UnityAction action)
public override DynamicUIElement AddListenerFunction(UnityAction action)
{
dropdown.onValueChanged.AddListener(_ => action());
return this;
}
}
}

View File

@@ -23,7 +23,7 @@ namespace Ichni.Editor
Observable.EveryUpdate().Subscribe(_ => text.text = content()).AddTo(gameObject);
}
public override void AddListenerFunction(UnityAction action)
public override DynamicUIElement AddListenerFunction(UnityAction action)
{
throw new System.NotImplementedException();
}

View File

@@ -71,9 +71,10 @@ namespace Ichni.Editor
connectedBaseElement.Refresh();
}
public override void AddListenerFunction(UnityAction action)
public override DynamicUIElement AddListenerFunction(UnityAction action)
{
inputField.onEndEdit.AddListener(_ => action());
return this;
}
}
}

View File

@@ -36,7 +36,7 @@ namespace Ichni.Editor
text.text = connectedBaseElement.GetType().GetField(parameterName).GetValue(connectedBaseElement).ToString();
}
public override void AddListenerFunction(UnityAction action)
public override DynamicUIElement AddListenerFunction(UnityAction action)
{
throw new NotImplementedException();
}

View File

@@ -35,9 +35,10 @@ namespace Ichni.Editor
connectedBaseElement.Refresh();
}
public override void AddListenerFunction(UnityAction action)
public override DynamicUIElement AddListenerFunction(UnityAction action)
{
dropdown.onValueChanged.AddListener(_ => action());
return this;
}
}
}

View File

@@ -31,9 +31,10 @@ namespace Ichni.Editor
connectedBaseElement.Refresh();
}
public override void AddListenerFunction(UnityAction action)
public override DynamicUIElement AddListenerFunction(UnityAction action)
{
toggle.onValueChanged.AddListener(_ => action());
return this;
}
}
}

View File

@@ -113,16 +113,13 @@ namespace Ichni.Editor
connectedBaseElement.Refresh();
}
public override void AddListenerFunction(UnityAction action)
public override DynamicUIElement AddListenerFunction(UnityAction action)
{
inputFieldX.onEndEdit.AddListener(_ => action());
inputFieldY.onEndEdit.AddListener(_ => action());
inputFieldZ.onEndEdit.AddListener(_ => action());
}
public override void DeviverSet(int i)
{
//我什么也不做
return this;
}
}
}