2025-07-08 10:46:31 +00:00
|
|
|
|
using Superlazy;
|
|
|
|
|
using Superlazy.UI;
|
|
|
|
|
|
|
|
|
|
public class SLUIValuePrefab : SLUIComponent
|
|
|
|
|
{
|
|
|
|
|
public string bindingValue;
|
|
|
|
|
public string tagID = "";
|
|
|
|
|
private bool UseTag => tagID != string.Empty;
|
|
|
|
|
|
|
|
|
|
private SLResourceObject current;
|
|
|
|
|
private string currentPath;
|
|
|
|
|
|
|
|
|
|
protected override void Init()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Validate()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Enable()
|
|
|
|
|
{
|
|
|
|
|
SLGame.AddNotify(bindParent.BindPath.CombinePath(bindingValue), OnChange);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void Disable()
|
|
|
|
|
{
|
|
|
|
|
SLGame.RemoveNotify(bindParent.BindPath.CombinePath(bindingValue), OnChange);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnChange()
|
|
|
|
|
{
|
|
|
|
|
if (bindParent.Active == false) return;
|
|
|
|
|
var sessionRoot = SLGame.SessionGet(bindParent.BindPath);
|
|
|
|
|
|
|
|
|
|
var newValue = sessionRoot.Get(bindingValue);
|
|
|
|
|
if (tagID != "")
|
|
|
|
|
{
|
|
|
|
|
newValue = SLTag.Apply(newValue, tagID);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (currentPath == newValue) return;
|
|
|
|
|
|
|
|
|
|
currentPath = newValue;
|
|
|
|
|
|
|
|
|
|
current?.Destroy();
|
|
|
|
|
current = SLResources.CreateInstance(newValue, transform);
|
|
|
|
|
}
|
|
|
|
|
}
|