public override void HandleInput()
 {
     //If current ui element is no longer being edited
     //Check for focused ui element which is is an interface bool that becomes true when on edit event is received
     //and false when oncancel event is recevied.
     //The page stores all focusable ui elements and the currently focused element.
     if (!InputToolMethod.IsInputRepeated() && Input.GetAxis("Cancel") != 0)
     {
         //Close current panel
         bool returnToStartPage = true;
         foreach (UIPage uiPage in uIPageHolder.initializedUIPages)
         {
             if (uiPage.isActive)
             {
                 foreach (IFocusUIElement focusElement in uiPage.FocusedUIElements)
                 {
                     bool focused = focusElement.IsThisElementInFocus();
                     if (focused)
                     {
                         returnToStartPage = false;
                         break;
                     }
                 }
             }
         }
         if (returnToStartPage)
         {
             foreach (UIPage uiPage in uIPageHolder.initializedUIPages)
             {
                 if (uiPage.GetComponent <IFocusUIElement>() == null)
                 {
                     uiPage.gameObject.SetActive(false);
                 }
             }
             UIToolMethods.OpenUIPanel(uIPageHolder.startPage.canvasTransform, uIPageHolder.startPage.gameObject.name);
         }
     }
     // Change to In game state
     //Condition
     //    inputHandlerUpdaterAttachedTo.CurrentInputHandler = (InputHandle rState)inputStateFactory.CreateProduct(
     //(int)FactoriesProducts.InputstateProducts.UINavigatorInGameState,this );
 }
예제 #2
0
    private GameObject AddButton(GameObject panel, UIButton uIButton)
    {
        GameObject newButton = UIToolMethods.AddUIButton(panel.transform, uIButton.buttonName);

        //Add functionality
        switch (uIButton.buttonFunction)
        {
        case UIButton.ButtonFunctions.ClosePanel:
            newButton.GetComponent <Button>().onClick.AddListener(delegate { UIToolMethods.DisableGameObject(uIButton.panelToOpen.name); });
            break;

        case UIButton.ButtonFunctions.OpenPanel:
            newButton.GetComponent <Button>().onClick.AddListener(delegate { UIToolMethods.OpenUIPanel(canvasTransform, uIButton.panelToOpen.name); });
            break;

        case UIButton.ButtonFunctions.LoadScene:
            newButton.GetComponent <Button>().onClick.AddListener(delegate { StartCoroutine(coroutineToolMethods.LoadScene(uIButton.sceneToOpen)); });
            break;

        case UIButton.ButtonFunctions.ExitGame:
            newButton.GetComponent <Button>().onClick.AddListener(delegate { UIToolMethods.ExitGame(); });
            break;

        case UIButton.ButtonFunctions.OpenUIPage:
            newButton.GetComponent <Button>().onClick.AddListener(delegate
            {
                UIToolMethods.OpenUIPanel(canvasTransform, uIButton.panelToOpen.name);
                UIToolMethods.DisableGameObject(gameObject.name);
            });
            break;
            //Complex UI functions can be added through adding a script component.
        }
        if (uIButton.usesCustomTransformProperty)
        {
            RectTransform buttonTransform = newButton.GetComponent <RectTransform>();
            buttonTransform.anchoredPosition = uIButton.buttonPosition;
            buttonTransform.localScale       = new Vector3(uIButton.buttonSize.x, uIButton.buttonSize.y, 0);
        }
        return(newButton);
    }