46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
using TMPro;
|
|
using uMVVM.Sources.Infrastructure;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace Game.MVVM.Model
|
|
{
|
|
public class MenuItemView : UnityGuiView<MenuItemViewModel>
|
|
{
|
|
private long id;
|
|
private string icon;
|
|
|
|
public Button btn;
|
|
public TMP_Text txtName;
|
|
|
|
protected override void OnInitialize()
|
|
{
|
|
base.OnInitialize();
|
|
this.Binder.Add<long>("MenuId", this.MenuIdOnValueChanged);
|
|
this.Binder.Add<string>("MenuName", this.MenuNameOnValueChanged);
|
|
this.Binder.Add<string>("MenuIcon", this.MenuIconOnValueChanged);
|
|
|
|
this.btn.onClick.AddListener(this.OnClickButton);
|
|
}
|
|
|
|
private void OnClickButton()
|
|
{
|
|
BindingContext.OnClick?.Invoke(this.id.ToString(), this.txtName.text);
|
|
}
|
|
|
|
private void MenuIdOnValueChanged(long oldvalue, long newvalue)
|
|
{
|
|
this.id = newvalue;
|
|
}
|
|
|
|
private void MenuNameOnValueChanged(string oldvalue, string newvalue)
|
|
{
|
|
this.txtName.text = newvalue;
|
|
}
|
|
|
|
private void MenuIconOnValueChanged(string oldvalue, string newvalue)
|
|
{
|
|
this.icon = newvalue;
|
|
}
|
|
}
|
|
} |