using System; using HuaweiService.Auth; using UnityEngine; using UnityEngine.UI; namespace HuaweiAuthDemo { [Serializable] public class ActionBar { public RectTransform container; public RectTransform content; public Transform title; public Transform separationLine; public Button closeButton; public Button backButton; } [Serializable] public class Footer { public RectTransform rectTransform; public Button secondaryActionButton; public Transform separationLine; } /// /// Base class for all panels /// public abstract class AbstractPanel : MonoBehaviour { private Canvas canvas; public AbstractPanel ParentPanel; public ActionBar actionBar; public Footer secondaryActionFooter; void Awake() { canvas = gameObject.GetComponent(); } public virtual void OpenPanel() { ShowPanel(); } public void ClosePanel() { HidePanel(); } public void Back() { HidePanel(); ParentPanel?.ShowPanel(); } protected virtual void ShowPanel() { canvas.enabled = true; } protected virtual void HidePanel() { // reset all input fields foreach (InputField inputField in GetComponentsInChildren()) inputField.text = null; canvas.enabled = false; } public void LogOutClick() { try { var instance = AGConnectAuth.getInstance(); if (instance != null) { instance.signOut(); PanelController.popupinstance.ShowInfo("User has been sign out!"); } else { PanelController.popupinstance.ShowInfo("Don't need log out, no user"); } } catch (System.Exception e) { Error error = new Error(); error.message = e.Message; PanelController.popupinstance.ShowError(error); } PanelController.getInstance() .OpenPanel(PanelController.getInstance().GetComponentInChildren()); } public bool haveCurrentUser(AbstractPanel parentPanel) { AGConnectUser user = AGConnectAuth.getInstance().getCurrentUser(); if (user==null) { return false; } ParentPanel = parentPanel; PanelController.getInstance() .OpenPanel(PanelController.getInstance().GetComponentInChildren()); return true; } } }