修该json

This commit is contained in:
2025-03-31 11:19:27 +08:00
parent ffcdddbd2a
commit 613e0f7f61
37 changed files with 10 additions and 6 deletions

View File

@@ -0,0 +1,53 @@
using UnityEngine;
using UnityEngine.UI;
namespace Stary.Evo.Example.Counter
{
public class CounterViewController : MonoBehaviour, IController
{
private Text _countText;
private ICounterData mCounterData;
void Start()
{
// 获取
mCounterData = this.GetData<ICounterData>();
mCounterData.Count.Register(UpdateView);
_countText = transform.Find("CountText").GetComponent<Text>();
_countText.text = mCounterData.Count.Value.ToString();
transform.Find("ButtonAdd").GetComponent<Button>()
.onClick.AddListener(() =>
{
// 交互逻辑
this.SendCommand<CommandAnd>();
});
transform.Find("ButtonSub").GetComponent<Button>()
.onClick.AddListener(() =>
{
// 交互逻辑
this.SendCommand<CommandSub>();
});
}
//表现逻辑
void UpdateView(int countValue)
{
_countText.text = countValue.ToString();
}
private void OnDestroy()
{
mCounterData.Count.Register(UpdateView);
mCounterData = null;
}
IArchitecture IBelongToArchitecture.GetArchitecture()
{
return CounterApp.Interface;
}
}
}