add "Pop canvas" for ButtonTriggerViewTransition

This commit is contained in:
alexiscatnip
2022-01-16 10:49:39 +08:00
parent a2e1acf74a
commit 3f9d7f9f9d
+15 -1
View File
@@ -6,6 +6,7 @@ using Raindrop;
using Raindrop.ServiceLocator;
using Raindrop.Services;
using UnityEngine;
using Logger = OpenMetaverse.Logger;
public class ButtonTriggerViewTransition : MonoBehaviour
{
@@ -13,11 +14,24 @@ public class ButtonTriggerViewTransition : MonoBehaviour
public bool popCurrent;
private void Start()
{
this.GetComponent<LeanButton>().OnClick.AddListener(OnClick);
try
{
this.GetComponent<LeanButton>().OnClick.AddListener(OnClick);
}
catch (Exception e)
{
Logger.DebugLog(e.ToString());
}
}
private void OnClick()
{
if (canvasTypeToPush == CanvasType.NONE)
{
ServiceLocator.Instance.Get<UIService>().canvasManager.PopCanvas();
return;
}
if (popCurrent)
{
ServiceLocator.Instance.Get<UIService>().canvasManager.PopAndPush(canvasTypeToPush);