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
        static void AddViewInViewStack()
        {
            RootCanvas.GetOrAddRootCanvas(); // Ensure there is a root canvas
            var view = AddViewToRootCanvas(ResourcesV2.LoadPrefab("Canvas/DefaultViewStackView"));

            view.name = "View " + (view.transform.GetSiblingIndex() + 1);
        }
Beispiel #3
0
        private static LogConsoleUi InitLogConsoleUi()
        {
            var targetCanvas   = RootCanvas.GetOrAddRootCanvas().gameObject;
            var toastContainer = targetCanvas.AddChild(ResourcesV2.LoadPrefab("Messages/LogConsoleUi1"));

            return(toastContainer.GetComponentInChildren <LogConsoleUi>());
        }
Beispiel #4
0
        private static SnackbarsUi InitSnackbarsUi()
        {
            var targetCanvas      = RootCanvas.GetOrAddRootCanvas().gameObject;
            var snackbarContainer = targetCanvas.AddChild(ResourcesV2.LoadPrefab("Messages/SnackbarContainer1"));

            return(snackbarContainer.GetOrAddComponent <SnackbarsUi>());
        }
Beispiel #5
0
        private static ProgressUi NewGlobalProgressUi(ProgressManager pm, string prefab = "Progress/GlobalProgressOverlay1")
        {
            ProgressUi progressUi;
            var        go = RootCanvas.GetOrAddRootCanvas().gameObject.AddChild(ResourcesV2.LoadPrefab(prefab));

            progressUi = go.GetComponentInChildren <ProgressUi>();
            progressUi.progressManager = pm;
            return(progressUi);
        }
Beispiel #6
0
        private static GameObject AddViewToRootCanvas(GameObject viewInViewStack)
        {
            Canvas rootCanvas = RootCanvas.GetOrAddRootCanvas();

            rootCanvas.gameObject.AddChild(viewInViewStack);
            viewInViewStack.name += " " + rootCanvas.gameObject.GetChildCount();
            viewInViewStack.GetOrAddComponent <RectTransform>().SetAnchorsStretchStretch();
            SelectInHirarchyUi(viewInViewStack);
            return(viewInViewStack);
        }
Beispiel #7
0
        private async Task SimulateConfirmButtonClick()
        {
            if (simulateUserInput)
            {
                await TaskV2.Delay(waitDurationPerDialogInMS);

                Log.d("Now simulating the user clicking on the confirm button");
                RootCanvas.GetOrAddRootCanvas().gameObject.GetLinkMap().Get <Button>("ConfirmButton").onClick.Invoke();
            }
        }
Beispiel #8
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 (select cancel or confirm) before the code continues!"));
            GameObject dialogUi = loader.LoadDialogPrefab(new ConfirmCancelDialog.DefaultPresenter(),
                                                          dialogPrefabName: "Dialogs/DefaultDialog1");

            RootCanvas.GetOrAddRootCanvas().gameObject.AddChild(dialogUi); // 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!");
        }
Beispiel #9
0
        public static IEnumerator RunTest <T>(string prefabName) where T : UnitTestMono
        {
            var ui = RootCanvas.GetOrAddRootCanvas().gameObject.AddComponent <ViewStack>().ShowView(prefabName);

            yield return(RunTest <T>(ui));
        }
Beispiel #10
0
 private static IEnumerable <GameObject> GetAllActiveViewsInViewStack()
 {
     return(RootCanvas.GetOrAddRootCanvas().gameObject.GetChildrenIEnumerable().Filter(v => v.activeInHierarchy));
 }
Beispiel #11
0
        /// <summary> Creates a new view stack and adds the specified Prefab to this stack </summary>
        /// <returns> The IEnumerator that can be awaited by the calling test </returns>
        public static IEnumerator LoadAndRunUiTest(string prefabName)
        {
            var viewStack = RootCanvas.GetOrAddRootCanvas().gameObject.AddComponent <ViewStack>();

            yield return(viewStack.ShowView(prefabName).FindAndRunTest());
        }