超级爆改
This commit is contained in:
@@ -13,16 +13,32 @@ namespace Ichni.Editor
|
||||
public TMP_InputField inputField;
|
||||
public bool isAutoUpdate { get; set; }
|
||||
public bool isReceiving { get; set; }
|
||||
private UnityAction<string> customAction;
|
||||
|
||||
public override void Initialize(IBaseElement baseElement, string title, string parameterName)
|
||||
{
|
||||
// [对象池安全]
|
||||
inputField.onEndEdit.RemoveListener(OnEndEditNode);
|
||||
inputField.onSelect.RemoveListener(OnSelectNode);
|
||||
inputField.onDeselect.RemoveListener(OnDeselectNode);
|
||||
customAction = null;
|
||||
|
||||
base.Initialize(baseElement, title, parameterName);
|
||||
|
||||
if (parameterName != string.Empty)
|
||||
{
|
||||
ApplyContent();
|
||||
inputField.onEndEdit.AddListener(ApplyParameters);
|
||||
inputField.onEndEdit.AddListener(OnEndEditNode);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEndEditNode(string str)
|
||||
{
|
||||
ApplyParameters(str);
|
||||
customAction?.Invoke(str);
|
||||
}
|
||||
private void OnSelectNode(string str) { isReceiving = false; }
|
||||
private void OnDeselectNode(string str) { isReceiving = true; }
|
||||
|
||||
private void Update()
|
||||
{
|
||||
@@ -44,8 +60,11 @@ namespace Ichni.Editor
|
||||
isAutoUpdate = enable;
|
||||
isReceiving = true;
|
||||
|
||||
inputField.onSelect.AddListener(_ => isReceiving = false);
|
||||
inputField.onDeselect.AddListener(_ => isReceiving = true);
|
||||
inputField.onSelect.RemoveListener(OnSelectNode);
|
||||
inputField.onSelect.AddListener(OnSelectNode);
|
||||
|
||||
inputField.onDeselect.RemoveListener(OnDeselectNode);
|
||||
inputField.onDeselect.AddListener(OnDeselectNode);
|
||||
}
|
||||
|
||||
public void ApplyContent()
|
||||
@@ -89,14 +108,14 @@ namespace Ichni.Editor
|
||||
}
|
||||
if (value != null)
|
||||
{
|
||||
ReflectionHelper.SetDeepValue(connectedBaseElement, parameterName, value);
|
||||
Ichni.Editor.Commands.CommandManager.ExecuteCommand(new Ichni.Editor.Commands.ChangeValueCommand(connectedBaseElement, parameterName, value));
|
||||
}
|
||||
connectedBaseElement.Refresh();
|
||||
}
|
||||
|
||||
public override DynamicUIElement AddListenerFunction(UnityAction action)
|
||||
{
|
||||
inputField.onEndEdit.AddListener(_ => action());
|
||||
customAction += _ => action();
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user