riversong code showcase
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace DanieleMarotta.RiversongCodeShowcase
|
||||
{
|
||||
[UIView("pause-popup")]
|
||||
public class PausePopupUIView : UIView
|
||||
{
|
||||
private Button _feedbackButton;
|
||||
|
||||
private Button _quitButton;
|
||||
|
||||
private EventCallback<ClickEvent> _onFeedbackButtonClick;
|
||||
|
||||
private EventCallback<ClickEvent> _onQuitButtonClick;
|
||||
|
||||
public event Action FeedbackButtonClick;
|
||||
|
||||
public event Action QuitButtonClick;
|
||||
|
||||
public override UniTask InitializeAsync(UIService uiService, VisualElement rootElement)
|
||||
{
|
||||
base.InitializeAsync(uiService, rootElement);
|
||||
|
||||
_feedbackButton = rootElement.Q<Button>(className: "pause-popup__feedback-button");
|
||||
_onFeedbackButtonClick = _ => FeedbackButtonClick?.Invoke();
|
||||
_feedbackButton.RegisterCallback(_onFeedbackButtonClick);
|
||||
|
||||
_quitButton = rootElement.Q<Button>(className: "pause-popup__quit-button");
|
||||
_onQuitButtonClick = _ => QuitButtonClick?.Invoke();
|
||||
_quitButton.RegisterCallback(_onQuitButtonClick);
|
||||
|
||||
return UniTask.CompletedTask;
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
_feedbackButton?.UnregisterCallback(_onFeedbackButtonClick);
|
||||
_quitButton?.UnregisterCallback(_onQuitButtonClick);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user