46 lines
1.1 KiB (Stored with Git LFS)
C#
46 lines
1.1 KiB (Stored with Git LFS)
C#
using UnityEngine;
|
|
|
|
namespace Superlazy.UI
|
|
{
|
|
public class SLUIValueScale : SLUIComponent
|
|
{
|
|
public string bindingValue;
|
|
|
|
private SLEntity oldValue;
|
|
|
|
protected override void Validate()
|
|
{
|
|
}
|
|
|
|
protected override void Init()
|
|
{
|
|
}
|
|
|
|
protected override void Enable()
|
|
{
|
|
if (bindingValue != string.Empty)
|
|
{
|
|
SLGame.AddNotify(bindParent.BindPath.CombinePath(bindingValue), OnChange);
|
|
}
|
|
}
|
|
|
|
protected override void Disable()
|
|
{
|
|
if (bindingValue != string.Empty)
|
|
{
|
|
SLGame.RemoveNotify(bindParent.BindPath.CombinePath(bindingValue), OnChange);
|
|
}
|
|
}
|
|
|
|
private void OnChange()
|
|
{
|
|
if (bindParent.Active == false) return;
|
|
|
|
var newValue = SLGame.SessionGet(bindParent.BindPath.CombinePath(bindingValue));
|
|
if (oldValue == newValue) return;
|
|
|
|
oldValue = newValue;
|
|
transform.localScale = Vector3.one * oldValue;
|
|
}
|
|
}
|
|
} |