Exemplo n.º 1
0
    public void AddWordButtonValue(WordButton butt)
    {
        if (nbWord == nbMaxWord)
        {
            return;
        }
        nbWord++;
        UnityEngine.Debug.Log(butt.word);
        sentenceWord.Add(butt.word);

        if (butt.FindSelectableOnRight() != null)
        {
            butt.FindSelectableOnRight().Select();
        }
        else if (butt.FindSelectableOnLeft() != null)
        {
            butt.FindSelectableOnLeft().Select();
        }
        else if (butt.FindSelectableOnUp() != null)
        {
            butt.FindSelectableOnUp().Select();
        }
        else if (butt.FindSelectableOnDown() != null)
        {
            butt.FindSelectableOnDown().Select();
        }

        butt.transform.SetParent(answerLine);
        UnityEngine.UI.Navigation nav = butt.navigation;
        nav.mode        = UnityEngine.UI.Navigation.Mode.None;
        butt.navigation = nav;

        butt.submitted = true;
    }
Exemplo n.º 2
0
    public void RemoveWordButtonValue(WordButton butt)
    {
        if (nbWord == 0)
        {
            return;
        }
        nbWord--;

        sentenceWord.Remove(butt.word);

        Transform toFeed = layouts[0];

        for (int i = 1; i < layouts.Length; i++)
        {
            if (layouts[i].childCount < toFeed.childCount)
            {
                toFeed = layouts[i];
            }
        }
        UnityEngine.UI.Navigation nav = butt.navigation;
        nav.mode        = UnityEngine.UI.Navigation.Mode.Automatic;
        butt.navigation = nav;
        butt.transform.SetParent(toFeed);
        butt.submitted = false;
    }
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.UI.Navigation o;
         o=new UnityEngine.UI.Navigation();
         pushValue(l,true);
         pushValue(l,o);
         return 2;
     }
     catch(Exception e) {
         return error(l,e);
     }
 }
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.UI.Navigation o;
         o=new UnityEngine.UI.Navigation();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
Exemplo n.º 5
0
    static int set_navigation(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.UI.Selectable obj  = (UnityEngine.UI.Selectable)o;
            UnityEngine.UI.Navigation arg0 = StackTraits <UnityEngine.UI.Navigation> .Check(L, 2);

            obj.navigation = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index navigation on a nil value"));
        }
    }
Exemplo n.º 6
0
    //****************************************************************************************************
    //
    //****************************************************************************************************

    public void ConfigureViewport()
    {
        if (viewport != null)
        {
            UnityEngine.UI.RawImage img = viewport.GetComponent <UnityEngine.UI.RawImage>();

            UnityEngine.UI.Button but = viewport.GetComponent <UnityEngine.UI.Button>();

            if (but == null)
            {
                but = viewport.gameObject.AddComponent <UnityEngine.UI.Button>();

                but.transition = UnityEngine.UI.Selectable.Transition.None;


                UnityEngine.UI.Navigation nav = new UnityEngine.UI.Navigation();

                nav.mode = UnityEngine.UI.Navigation.Mode.None;

                but.navigation = nav;
            }

            if (but != null)
            {
                but.interactable = true;

                but.onClick.RemoveAllListeners();

                but.onClick.AddListener(delegate { SelectItemUserDatas(null); });
            }

            if (img != null)
            {
                img.raycastTarget = true;
            }
        }
    }
        private void Hover(VRTK_UIPointer pointer, List<RaycastResult> results)
        {
            if (pointer.pointerEventData.pointerEnter)
            {
                if (NoValidCollision(pointer, results))
                {
                    ExecuteEvents.ExecuteHierarchy(pointer.pointerEventData.pointerEnter, pointer.pointerEventData, ExecuteEvents.pointerExitHandler);
                    pointer.pointerEventData.hovered.Remove(pointer.pointerEventData.pointerEnter);
                    pointer.pointerEventData.pointerEnter = null;
                }
            }
            else
            {
                foreach (var result in results)
                {
                    var target = ExecuteEvents.ExecuteHierarchy(result.gameObject, pointer.pointerEventData, ExecuteEvents.pointerEnterHandler);
                    if (target != null)
                    {
                        var selectable = target.GetComponent<Selectable>();
                        if (selectable)
                        {
                            var noNavigation = new Navigation();
                            noNavigation.mode = Navigation.Mode.None;
                            selectable.navigation = noNavigation;
                        }

                        pointer.pointerEventData.pointerCurrentRaycast = result;
                        pointer.pointerEventData.pointerEnter = target;
                        pointer.pointerEventData.hovered.Add(pointer.pointerEventData.pointerEnter);
                        break;
                    }
                }
            }
        }
 static public int get_selectOnRight(IntPtr l)
 {
     UnityEngine.UI.Navigation o = (UnityEngine.UI.Navigation)checkSelf(l);
     pushValue(l, o.selectOnRight);
     return(1);
 }
 static public int get_mode(IntPtr l)
 {
     UnityEngine.UI.Navigation o = (UnityEngine.UI.Navigation)checkSelf(l);
     pushEnum(l, (int)o.mode);
     return(1);
 }
Exemplo n.º 10
0
    private OnScreenKeyboardKey[] GenerateKeys(int row, GameObject keyRoot, OnScreenKeyboardRowBuilder builder, OnScreenKeyboardKey template)
    {
        OnScreenKeyboardKey[] results = new OnScreenKeyboardKey[builder.keyCount];
        //Loop through and generate the keys
        for (int i = 0; i < builder.keyCount; i++)
        {
            //Generate a new key object with an OnScreenKeyboardKey component
            GameObject key = GameObject.Instantiate(template.gameObject) as GameObject;

            UnityEngine.UI.Button     keyButton  = key.GetComponent <UnityEngine.UI.Button>();
            UnityEngine.UI.Navigation navPointer = keyButton.navigation;
            navPointer.mode = UnityEngine.UI.Navigation.Mode.Explicit;

            key.name = "Row:" + row.ToString() + " Column:" + i.ToString();
            //Incase we have our template in our scene as disabled
            key.SetActive(true);
            //Get a pointer to the component
            OnScreenKeyboardKey screenKey = key.GetComponent <OnScreenKeyboardKey>();
            key.transform.SetParent(keyRoot.transform, false);
            key.transform.localPosition    = Vector3.zero;
            key.transform.localEulerAngles = Vector3.zero;
            //Set its values
            screenKey.keyCode        = builder.keyCodeValues[i];
            screenKey.UpperCaseValue = builder.upperValues[i];
            screenKey.LowerCaseValue = builder.lowerValues[i];
            screenKey.type           = builder.types[i];

            //And we are going to start in lower so set the key value accordingly
            if (builder.upperValues[i].Trim() == "")
            {
                screenKey.Text.text = "_";
            }
            else
            {
                screenKey.Text.text = builder.lowerValues[i];
            }

            //While we are here lets setup our left navigation and our buddies right nav
            if (i > 0)
            {
                navPointer.selectOnLeft = results[i - 1].GetComponent <UnityEngine.UI.Button>();

                UnityEngine.UI.Navigation nNav = results[i - 1].GetComponent <UnityEngine.UI.Button>().navigation;
                nNav.selectOnRight = keyButton;
                results[i - 1].GetComponent <UnityEngine.UI.Button>().navigation = nNav;
            }

            results[i] = screenKey;

            keyButton.navigation = navPointer;
        }
        //Our right nave for the last key isnt set yet so set it here
        UnityEngine.UI.Navigation lastNav = results[results.Length - 1].GetComponent <UnityEngine.UI.Button>().navigation;
        lastNav.selectOnRight = results[0].GetComponent <UnityEngine.UI.Button>();
        results[results.Length - 1].GetComponent <UnityEngine.UI.Button>().navigation = lastNav;

        //results[results.Length-1].RightKey = results[0];
        UnityEngine.UI.Navigation firstNav = results[0].GetComponent <UnityEngine.UI.Button>().navigation;
        firstNav.selectOnLeft = results[results.Length - 1].GetComponent <UnityEngine.UI.Button>();
        results[0].GetComponent <UnityEngine.UI.Button>().navigation = firstNav;
        //results[0].LeftKey = results[results.Length-1];
        return(results);
    }
Exemplo n.º 11
0
    private void GenerateObjects(OnScreenKeyboard subject)
    {
        //Before we start to loop and create lets create a root object so we can shift the keyboard keys as a set easily
        if (lastRootBuilt != null)
        {
            GameObject.DestroyImmediate(lastRootBuilt);
        }

        lastRootBuilt = new GameObject("Keys", typeof(UnityEngine.UI.VerticalLayoutGroup));
        lastRootBuilt.transform.SetParent(subject.gameObject.transform, false);

        RectTransform rTrans = lastRootBuilt.GetComponent <RectTransform>();

        rTrans.anchorMax        = Vector2.one;
        rTrans.anchorMin        = Vector2.zero;
        rTrans.anchoredPosition = Vector2.zero;
        rTrans.sizeDelta        = Vector2.zero;

        List <OnScreenKeyboardKey[]> RowsBuilt = new List <OnScreenKeyboardKey[]>();
        int rowCounter = 0;

        foreach (OnScreenKeyboardRowBuilder builder in RowStructure)
        {
            GameObject rowRoot = new GameObject("Row " + (rowCounter + 1).ToString(), typeof(UnityEngine.UI.HorizontalLayoutGroup));

            rowRoot.transform.parent           = lastRootBuilt.transform;
            rowRoot.transform.localPosition    = Vector3.zero;
            rowRoot.transform.localEulerAngles = Vector3.zero;
            OnScreenKeyboardKey[] nRow = GenerateKeys(rowCounter, rowRoot, builder, subject.KeyTemplate);
            RowsBuilt.Add(nRow);
            rowCounter++;
        }

        //Once we have them all built we need to link the up and down navigations
        int rowIndex = 0;

        foreach (OnScreenKeyboardKey[] row in RowsBuilt)
        {
            int PreviousRow = rowIndex - 1;
            int NextRow     = rowIndex + 1;

            if (NextRow >= RowsBuilt.Count)
            {
                NextRow = 0;
            }
            if (PreviousRow < 0)
            {
                PreviousRow = RowsBuilt.Count - 1;
            }

            for (int i = 0; i < row.Length; i++)
            {
                UnityEngine.UI.Navigation navPointer = row[i].GetComponent <UnityEngine.UI.Button>().navigation;
                //row upper link to previous row
                if (i < RowsBuilt[PreviousRow].Length)
                {
                    navPointer.selectOnUp = RowsBuilt[PreviousRow][i].GetComponent <UnityEngine.UI.Button>();
                    //row[i].UpKey = RowsBuilt[PreviousRow][i];
                }
                else
                {
                    navPointer.selectOnUp = RowsBuilt[PreviousRow][RowsBuilt[PreviousRow].Length - 1].GetComponent <UnityEngine.UI.Button>();
                    //row[i].UpKey = RowsBuilt[PreviousRow][RowsBuilt[PreviousRow].Length-1];
                }

                //row lower link to next row
                if (i < RowsBuilt[NextRow].Length)
                {
                    navPointer.selectOnDown = RowsBuilt[NextRow][i].GetComponent <UnityEngine.UI.Button>();
                    //row[i].DownKey = RowsBuilt[NextRow][i];
                }
                else
                {
                    navPointer.selectOnDown = RowsBuilt[NextRow][RowsBuilt[NextRow].Length - 1].GetComponent <UnityEngine.UI.Button>();
                    //row[i].DownKey = RowsBuilt[NextRow][RowsBuilt[NextRow].Length-1];
                }

                row[i].GetComponent <UnityEngine.UI.Button>().navigation = navPointer;
            }

            rowIndex++;
        }
        //Finnaly we want to update the OnScreenKeyboard structure to render the results
        subject.UpdateStructure();
    }
		public IButtonComponent SetNavigationMode(Navigation.Mode mode) {

			if (this.button != null) {

				var nav = this.button.navigation;
				nav.mode = mode;
				this.button.navigation = nav;

			}

			return this;

		}
Exemplo n.º 13
0
 /// <summary>
 /// Configures buttons for navigation
 /// </summary>
 /// <param name="pointer">The pointer to configure.</param>
 /// <param name="character">Character the pointer belongs to</param>
 /// <param name="sortedCharacterList">Sorted list of friendly or enemy characters (same group which [[CHARACTER]] belongs to).</param>
 /// <param name="oppositePointers">Pointers for other group (i.e. if [[CHARACTER]] is friendly, then enemy pointer list).</param>
 /// <param name="oppositeSortedCharacters">Sorted list for other group (i.e. if [[CHARACTER]] is friendly, then enemy characters list).</param>
 private void SetButtonNavigation(GameObject pointer, AbstractBattleCharacter character, List<AbstractBattleCharacter> sortedCharacterList, Dictionary<AbstractBattleCharacter, GameObject> oppositePointers, List<AbstractBattleCharacter> oppositeSortedCharacters)
 {
     var button = pointer.GetComponentInChildren<Button>();
     Navigation navigation = new Navigation {mode = Navigation.Mode.Explicit};
     navigation.selectOnUp = navigation.selectOnDown = navigation.selectOnUp = navigation.selectOnDown = oppositePointers[oppositeSortedCharacters[0]].GetComponentInChildren<Button>();
     navigation.selectOnLeft = ToLeft(character, sortedCharacterList).GetComponentInChildren<Button>();
     navigation.selectOnRight = ToRight(character, sortedCharacterList).GetComponentInChildren<Button>();
     button.navigation = navigation;
 }
        private void Hover(VRTK_UIPointer pointer, List<RaycastResult> results)
        {
            if (pointer.pointerEventData.pointerEnter)
            {
                if (ShouldIgnoreElement(pointer.pointerEventData.pointerEnter, pointer.ignoreCanvasWithTagOrClass, pointer.canvasTagOrScriptListPolicy))
                {
                    return;
                }

                if (NoValidCollision(pointer, results))
                {
                    ExecuteEvents.ExecuteHierarchy(pointer.pointerEventData.pointerEnter, pointer.pointerEventData, ExecuteEvents.pointerExitHandler);
                    pointer.pointerEventData.hovered.Remove(pointer.pointerEventData.pointerEnter);
                    pointer.pointerEventData.pointerEnter = null;
                }
            }
            else
            {
                foreach (var result in results)
                {
                    if (ShouldIgnoreElement(result.gameObject, pointer.ignoreCanvasWithTagOrClass, pointer.canvasTagOrScriptListPolicy))
                    {
                        continue;
                    }

                    var target = ExecuteEvents.ExecuteHierarchy(result.gameObject, pointer.pointerEventData, ExecuteEvents.pointerEnterHandler);
                    if (target != null)
                    {
                        var selectable = target.GetComponent<Selectable>();
                        if (selectable)
                        {
                            var noNavigation = new Navigation();
                            noNavigation.mode = Navigation.Mode.None;
                            selectable.navigation = noNavigation;
                        }

                        pointer.OnUIPointerElementEnter(pointer.SetUIPointerEvent(target, pointer.hoveringElement));
                        pointer.hoveringElement = target;
                        pointer.pointerEventData.pointerCurrentRaycast = result;
                        pointer.pointerEventData.pointerEnter = target;
                        pointer.pointerEventData.hovered.Add(pointer.pointerEventData.pointerEnter);
                        break;
                    }
                    else
                    {
                        if (result.gameObject != pointer.hoveringElement)
                        {
                            pointer.OnUIPointerElementEnter(pointer.SetUIPointerEvent(result.gameObject, pointer.hoveringElement));
                        }
                        pointer.hoveringElement = result.gameObject;
                    }
                }

                if (pointer.hoveringElement && results.Count == 0)
                {
                    pointer.OnUIPointerElementExit(pointer.SetUIPointerEvent(null, pointer.hoveringElement));
                    pointer.hoveringElement = null;
                }
            }
        }