Beispiel #1
0
        private static ToastsUi InitToastsUi()
        {
            var targetCanvas   = RootCanvas.GetOrAddRootCanvas().gameObject;
            var toastContainer = targetCanvas.AddChild(ResourcesV2.LoadPrefab("Messages/ToastContainer1"));

            return(toastContainer.GetOrAddComponent <ToastsUi>());
        }
Beispiel #2
0
        private static SnackbarsUi InitSnackbarsUi()
        {
            var targetCanvas      = RootCanvas.GetOrAddRootCanvasV2().gameObject;
            var snackbarContainer = targetCanvas.AddChild(ResourcesV2.LoadPrefab("Messages/SnackbarContainer1"));

            return(snackbarContainer.GetOrAddComponent <SnackbarsUi>());
        }
Beispiel #3
0
        public GameObject Show(string toastCaption, string toastMessage, int displayDurationInMs)
        {
            var newToast     = ResourcesV2.LoadPrefab("Messages/Toast");
            var toastUiElems = newToast.GetLinkMap();

            InitText(toastUiElems, "Caption", toastCaption);
            InitText(toastUiElems, "Message", toastMessage);
            newToast.GetComponentV2 <MonoBehaviour>().ExecuteDelayed(() => newToast.Destroy(), displayDurationInMs);
            toastsContainer.AddChild(newToast);
            return(newToast);
        }
Beispiel #4
0
        public GameObject Show(string snackbarMsg, string buttonMsg, Action <GameObject> snackbarAction, int displayDurationInMs)
        {
            var newSnackbar = ResourcesV2.LoadPrefab("Messages/Snackbar");
            var map         = newSnackbar.GetLinkMap();

            map.Get <Text>("Message").text = snackbarMsg;
            if (snackbarAction != null && !buttonMsg.IsNullOrEmpty())
            {
                map.Get <Text>("SnackbarButton").text = buttonMsg;
                map.Get <Button>("SnackbarButton").SetOnClickAction(snackbarAction);
            }
            else
            {
                map.Get <GameObject>("SnackbarButton").Destroy();
            }
            newSnackbar.GetComponentV2 <MonoBehaviour>().ExecuteDelayed(() => newSnackbar.Destroy(), displayDurationInMs);
            snackbarsContainer.AddChild(newSnackbar);
            return(newSnackbar);
        }