// ------------------
        static public void SetEventSystemSelectedObject(GameObject o)
        {
            UnityEngine.EventSystems.EventSystem s = UnityEngine.EventSystems.EventSystem.current;
            if (s != null)
            {
                s.firstSelectedGameObject = o;

                if (s.currentInputModule is ControlFreak2.GamepadInputModule)
                {
                    s.SetSelectedGameObject(null, null);
                    s.SetSelectedGameObject(o, null);
                }
            }
        }
Ejemplo n.º 2
0
        void Update()
        {
            RaycastHit hit;
            Button     button = null;

            // do a forward raycast to see if we hit a Button
            if (Physics.Raycast(transform.position, transform.forward, out hit, 50f))
            {
                button = hit.collider.GetComponent <Button>();
            }

            if (button != null)
            {
                if (m_currentButton != button)
                {
                    m_currentButton = button;
                    m_currentButton.Select();
                }
            }
            else if (m_currentButton != null)
            {
                m_currentButton = null;
                if (m_eventSystem != null)
                {
                    m_eventSystem.SetSelectedGameObject(null);
                }
            }
        }
Ejemplo n.º 3
0
        public void InitMenuManager()
        {
            MenuPage curMenuPageScript = defaultMenuPage.GetComponent <MenuPage>();

            eventSystemScript = eventSystem.GetComponent <UnityEngine.EventSystems.EventSystem>();

            InitMenuPage(defaultMenuPage, curMenuPageScript);
            curMenuPages.Add(curMenuPageScript);

            // assign first button selection to the menu page / menu container / menu button in each respective first index
            if (curMenuPages.Count() > 0)
            {
                List <ButtonContainer> curMenuPageButtonContainers = curMenuPages[0].buttonContainerScripts;
                if (curMenuPageButtonContainers.Count() > 0)
                {
                    if (curMenuPageButtonContainers[0].childMenuButtonScripts.Count > 0)
                    {
                        eventSystemScript.SetSelectedGameObject(curMenuPageButtonContainers[0].childMenuButtonScripts[0].gameObject);
                    }
                    else
                    {
                        Debug.Log("there were no buttons in the first index button container to assign first selection");
                    }
                }
                else
                {
                    Debug.Log("there were no button containers in the first index menu page to assign first selection");
                }
            }
            else
            {
                Debug.Log("there were no menu pages created in order to assign a first selection");
            }
        }
Ejemplo n.º 4
0
 void UpdateButtonInteractivity()
 {
     mBackButton.interactable = mCurrentSlide != 0;
     mNextButton.interactable = mCurrentSlide != (mTutorialSlides.Length - 1);
     if (mCurrentSlide == 0 || mCurrentSlide == mTutorialSlides.Length - 1)
     {
         mUiEventSystem.SetSelectedGameObject(mUiEventSystem.firstSelectedGameObject);
     }
 }
Ejemplo n.º 5
0
        IEnumerator SelectButtonInUI(GameObject Btn)
        {
            yield return(new WaitForSeconds(0.25f));

            eventSystem.SetSelectedGameObject(Btn);

            if (Btn.GetComponent <UnityEngine.UI.Button>())
            {
                Btn.GetComponent <UnityEngine.UI.Button>().Select();
            }
        }
Ejemplo n.º 6
0
        static int _m_SetSelectedGameObject(RealStatePtr L)
        {
            try {
                ObjectTranslator translator = ObjectTranslatorPool.Instance.Find(L);


                UnityEngine.EventSystems.EventSystem gen_to_be_invoked = (UnityEngine.EventSystems.EventSystem)translator.FastGetCSObj(L, 1);


                int gen_param_count = LuaAPI.lua_gettop(L);

                if (gen_param_count == 2 && translator.Assignable <UnityEngine.GameObject>(L, 2))
                {
                    UnityEngine.GameObject _selected = (UnityEngine.GameObject)translator.GetObject(L, 2, typeof(UnityEngine.GameObject));

                    gen_to_be_invoked.SetSelectedGameObject(_selected);



                    return(0);
                }
                if (gen_param_count == 3 && translator.Assignable <UnityEngine.GameObject>(L, 2) && translator.Assignable <UnityEngine.EventSystems.BaseEventData>(L, 3))
                {
                    UnityEngine.GameObject _selected = (UnityEngine.GameObject)translator.GetObject(L, 2, typeof(UnityEngine.GameObject));
                    UnityEngine.EventSystems.BaseEventData _pointer = (UnityEngine.EventSystems.BaseEventData)translator.GetObject(L, 3, typeof(UnityEngine.EventSystems.BaseEventData));

                    gen_to_be_invoked.SetSelectedGameObject(_selected, _pointer);



                    return(0);
                }
            } catch (System.Exception gen_e) {
                return(LuaAPI.luaL_error(L, "c# exception:" + gen_e));
            }

            return(LuaAPI.luaL_error(L, "invalid arguments to UnityEngine.EventSystems.EventSystem.SetSelectedGameObject!"));
        }
        static StackObject *SetSelectedGameObject_14(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            CSHotFix.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            UnityEngine.GameObject @selected = (UnityEngine.GameObject) typeof(UnityEngine.GameObject).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            UnityEngine.EventSystems.EventSystem instance_of_this_method = (UnityEngine.EventSystems.EventSystem) typeof(UnityEngine.EventSystems.EventSystem).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            instance_of_this_method.SetSelectedGameObject(@selected);

            return(__ret);
        }
        public IEnumerator StartDialogue(DialogueNode dialogue)
        {
            if (!isInDialogue)
            {
                isInDialogue = true;
                Reset();
                anim.SetBool("Activated", true);
                yield return(new WaitForSeconds(.5f));

                while (true)
                {
                    nameText.text     = dialogue.currentNameText;
                    currentAudioClips = GetRightAudioClips(dialogue.currentVoice);

                    if (PauseManager.isPaused().Value)
                    {
                        yield return(new WaitWhile(() => PauseManager.isPaused().Value));
                    }

                    yield return(TypeSentence(dialogue.currentText));

                    if (Input.GetKeyDown(KeyCode.L))
                    {
                        break;
                    }

                    if (dialogue.currentChoices != null && dialogue.currentChoices.Count > 0)
                    {
                        choices[0].GetComponentInChildren <Text>().text = dialogue.currentChoices[0];
                        choices[0].SetActive(true);
                        eventSystem.SetSelectedGameObject(choices[0]);

                        switch (dialogue.nextNodes.Count)
                        {
                        case 1:
                            break;

                        case 2:
                            choices[1].GetComponentInChildren <Text>().text = dialogue.currentChoices[1];
                            choices[1].SetActive(true);
                            break;

                        case 3:
                            choices[2].GetComponentInChildren <Text>().text = dialogue.currentChoices[2];
                            choices[2].SetActive(true);
                            goto case 2;

                        default:
                            Debug.LogWarning("More than 3 choices are not implemented yet.");
                            break;
                        }
                        anim.SetBool("Choices", true);
                        pressedChoice = -1;
                        yield return(new WaitWhile(() => pressedChoice == -1 || IsPressingConfirm()));

                        if (pressedChoice < 1 || pressedChoice > 3)
                        {
                            Debug.LogError("unsupported choice");
                        }

                        dialogue = dialogue.nextNodes[pressedChoice - 1];
                        anim.SetBool("Choices", false);
                        eventSystem.SetSelectedGameObject(null);
                        choices[0].SetActive(false);
                        choices[1].SetActive(false);
                        choices[2].SetActive(false);
                    }
                    else
                    {
                        yield return(new WaitUntil(() => (!PauseManager.isPaused().Value&& IsPressingConfirm())));

                        yield return(new WaitUntil(() => (!PauseManager.isPaused().Value&& !IsPressingConfirm())));

                        if (dialogue.nextNodes.Count == 0)
                        {
                            break;
                        }
                        if (dialogue.nextNodes[0].currentText == null)
                        {
                            ending = dialogue.nextNodes[0].end;
                            break;
                        }


                        dialogue = dialogue.nextNodes[0];
                    }
                }

                anim.SetBool("Activated", false);
                isInDialogue = false;
            }
        }
Ejemplo n.º 9
0
 private void Start()
 {
     inventoryEnabled = false;
     go = m_hero.m_FirstInventorySlot;
     eventSystem.SetSelectedGameObject(go);
 }