riversong code showcase
This commit is contained in:
45
Source/Riversong/Game/UI/Panels/TimePanel/TimePanelUIView.cs
Normal file
45
Source/Riversong/Game/UI/Panels/TimePanel/TimePanelUIView.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace DanieleMarotta.RiversongCodeShowcase
|
||||
{
|
||||
[UIView("time-panel")]
|
||||
public class TimePanelUIView : UIView<TimePanelModel>
|
||||
{
|
||||
private Label _weekNumberText;
|
||||
|
||||
private Label _monthNumberText;
|
||||
|
||||
private Label _yearNumberText;
|
||||
|
||||
public override async UniTask InitializeAsync(UIService uiService, VisualElement rootElement)
|
||||
{
|
||||
await base.InitializeAsync(uiService, rootElement);
|
||||
|
||||
_weekNumberText = rootElement.Q<Label>(className: "time-panel__week-number");
|
||||
_monthNumberText = rootElement.Q<Label>(className: "time-panel__month-number");
|
||||
_yearNumberText = rootElement.Q<Label>(className: "time-panel__year-number");
|
||||
}
|
||||
|
||||
protected override void OnNewModel(TimePanelModel model)
|
||||
{
|
||||
base.OnNewModel(model);
|
||||
|
||||
UpdateText();
|
||||
}
|
||||
|
||||
protected override void OnModelPropertyChanged(object sender, BindablePropertyChangedEventArgs e)
|
||||
{
|
||||
base.OnModelPropertyChanged(sender, e);
|
||||
|
||||
UpdateText();
|
||||
}
|
||||
|
||||
private void UpdateText()
|
||||
{
|
||||
_weekNumberText.text = $"Week {Model.Week + 1},";
|
||||
_monthNumberText.text = $"Month {Model.Month + 1},";
|
||||
_yearNumberText.text = $"Year {Model.Year + 1}";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user