超级爆改

This commit is contained in:
SoulliesOfficial
2026-03-22 12:05:32 -04:00
parent f28bc68518
commit 731726239a
1959 changed files with 8890135 additions and 2222 deletions

View File

@@ -22,18 +22,31 @@ namespace Ichni.Editor
this.buttonText.text = buttonText;
}
private UnityAction customAction;
private UnityAction appliedFunction;
public void ApplyFunction(UnityAction function)
{
button.onClick.AddListener(function);
if (connectedBaseElement != null)
{
button.onClick.AddListener(connectedBaseElement.Refresh);
}
// [对象池安全] 改为只清除我们自己挂载的动作,避免杀掉预制体内置的动效
if (appliedFunction != null) button.onClick.RemoveListener(appliedFunction);
button.onClick.RemoveListener(OnButtonClick);
customAction = null;
appliedFunction = function;
button.onClick.AddListener(appliedFunction);
button.onClick.AddListener(OnButtonClick);
}
private void OnButtonClick()
{
if (connectedBaseElement != null) connectedBaseElement.Refresh();
customAction?.Invoke();
}
public override DynamicUIElement AddListenerFunction(UnityAction action)
{
button.onClick.AddListener(action);
customAction += action;
return this;
}
}