using UniRx;
using UnityEngine.UI;
using UnityEngine;
namespace TestGame
{
public class TestModel : MonoBehaviour
{
[SerializeField]
private Button button;//ボタン
[SerializeField]
private int addValue;//加える数
[HideInInspector]
public ReactiveProperty<int> Counter
= new();//ReactiveProperty//ボタン取得用
public Button Button { get => button; }
public void AddCounter()
{
//カウントを一定数増やす
Counter.Value += addValue;
}
}
}
TestView.cs(View)
using DG.Tweening;
using UnityEngine.UI;
using UnityEngine;
namespace TestGame
{
public class TestView : MonoBehaviour
{
[SerializeField]
private Text txtCount;//カウントのテキスト
public void UpdateTxtCount(int oldValue, int newValue)
{
//0.5秒掛けて表示を変化させる
txtCount.DOCounter(oldValue, newValue, 0.5f);
}
}
}
コメント