Example #1
0
        private static SnackbarsUi InitSnackbarsUi()
        {
            var targetCanvas      = RootCanvas.GetOrAddRootCanvasV2().gameObject;
            var snackbarContainer = targetCanvas.AddChild(ResourcesV2.LoadPrefab("Messages/SnackbarContainer1"));

            return(snackbarContainer.GetOrAddComponent <SnackbarsUi>());
        }
Example #2
0
        private static LogConsoleUi InitLogConsoleUi()
        {
            var targetCanvas   = RootCanvas.GetOrAddRootCanvasV2().gameObject;
            var toastContainer = targetCanvas.AddChild(ResourcesV2.LoadPrefab("Messages/LogConsoleUi1"));

            return(toastContainer.GetComponentInChildren <LogConsoleUi>());
        }
Example #3
0
        private static ToastsUi InitToastsUi()
        {
            var targetCanvas   = RootCanvas.GetOrAddRootCanvasV2().gameObject;
            var toastContainer = targetCanvas.AddChild(ResourcesV2.LoadPrefab("Messages/ToastContainer1"));

            return(toastContainer.GetOrAddComponent <ToastsUi>());
        }
Example #4
0
        private static ProgressUi NewGlobalProgressUi(ProgressManager pm, string prefab = "Progress/GlobalProgressOverlay1")
        {
            ProgressUi progressUi;
            var        go = RootCanvas.GetOrAddRootCanvasV2().gameObject.AddChild(ResourcesV2.LoadPrefab(prefab));

            progressUi = go.GetComponentInChildren <ProgressUi>();
            progressUi.progressManager = pm;
            return(progressUi);
        }
Example #5
0
        /// <summary> This example shows how to use the DialogLoader manually to have full control over the UI presenter </summary>
        private async Task UseDialogLoaderManually()
        {
            var loader = new DialogLoader <ConfirmCancelDialog>(new ConfirmCancelDialog(caption: "I am a dialog",
                                                                                        message: "I can be awaited in the code, the async or coroutine can wait for the user " +
                                                                                        "to make a decision before the code continues!", "Ok, I understand"));
            var rootCanvas = RootCanvas.GetOrAddRootCanvasV2().gameObject;

            rootCanvas.AddChild(loader.LoadDialogPrefab(new ConfirmCancelDialog.DefaultPresenter(),
                                                        dialogPrefabName: "Dialogs/DefaultDialog1")); // Add dialog UI in a canvas
            var waitForUserInputInDialogTask = loader.ShowDialogAsync();

            AssertV2.IsFalse(loader.data.dialogWasConfirmed, "Dialog was already confirmed!");
            await SimulateConfirmButtonClick();

            ConfirmCancelDialog dialog = await waitForUserInputInDialogTask; // Wait until user clicks cancel or confirm

            AssertV2.IsTrue(dialog.dialogWasConfirmed, "Dialog was not confirmed!");
        }
Example #6
0
        /// <summary> The first example here demonstrates how a progress manager can be
        /// created and then shown in a global progress UI (that is eg shown on top of all
        /// screens). This manager can be set as a global singlton to use it from anywhere
        /// in your logic and show overall progress indication of background tasks to the
        /// user to give them a sense of the amount of work that is currently happening
        /// and when it will approximatly be done. </summary>
        private void SetupGlobalProgressUi()
        {
            var pm1             = new ProgressManager();
            var uisInRootCanvas = RootCanvas.GetOrAddRootCanvasV2().gameObject.GetChildren();
            // Find the single one that has a progress UI attached to it and assume its the global process UI screen to be used:
            var globalProgressUi = uisInRootCanvas.Single(x => x.GetComponentV2 <ProgressUi>() != null).GetComponentV2 <ProgressUi>();

            globalProgressUi.progressManager = pm1;

            int id  = 0;
            var map = gameObject.GetLinkMap();

            map.Get <Button>("NewProgress").SetOnClickAction(delegate {
                id++;
                pm1.GetOrAddProgress("Progress:" + id, totalCount, true);
            });
            map.Get <Button>("IncrementCurrentProgress").SetOnClickAction(delegate {
                pm1.GetProgress("Progress:" + id).IncrementCount();
            });
        }