33 lines
829 B
C#
Raw Normal View History

2024-12-14 18:27:59 +08:00
using UnityEngine;
namespace QFramework.Example
{
public class BindablePropertyExample : MonoBehaviour
{
private BindableProperty<int> mSomeValue = new BindableProperty<int>(0);
private BindableProperty<string> mName = new BindableProperty<string>("QFramework");
void Start()
{
mSomeValue.Register(newValue =>
{
Debug.Log(newValue);
}).UnRegisterWhenGameObjectDestroyed(gameObject);
mName.RegisterWithInitValue(newName =>
{
Debug.Log(mName);
}).UnRegisterWhenGameObjectDestroyed(gameObject);
}
void Update()
{
if (Input.GetMouseButtonDown(0))
{
mSomeValue.Value++;
}
}
}
}