Example #1
0
        /// <summary>
        ///  change the color of the two canvas included in C
        /// </summary>
        /// <param name="C">the canva that we want to update</param>
        public void ModifyCanva()
        {
            //TODO select Values by their tag

            int currentLine = 0;

            if (GameObjectHelper.FindNumberOfChildsWithTag(Values.gameObject, "UiLine") > 0)
            {
                for (int i = 0; i < Values.transform.childCount; i++) // for all the childs
                {
                    if (Values.transform.GetChild(i).tag == "UiLine") // but only thoses who r a button with text
                    {
                        if (currentLine == lineNumber)                // is this the highlighted one's ?
                        {
                            var colors = Values.transform.GetChild(i).GetComponent <UnityEngine.UI.Button>().colors;
                            colors.normalColor = Color.red;
                            Values.transform.GetChild(i).GetComponent <UnityEngine.UI.Button>().colors = colors;

                            Values.transform.GetChild(i).GetComponentInChildren <TMP_Text>().color = Color.white;
                        }
                        else
                        {
                            var colors = Values.transform.GetChild(i).GetComponent <UnityEngine.UI.Button>().colors;
                            colors.normalColor = Color.white;
                            Values.transform.GetChild(i).GetComponent <UnityEngine.UI.Button>().colors = colors;

                            Values.transform.GetChild(i).GetComponentInChildren <TMP_Text>().color = Color.red;
                        }
                        currentLine++;
                    }
                }
            }
        }
Example #2
0
        /// <summary>
        /// updates the UI if there are any
        /// </summary>
        void Update()
        {
            if (selectablesUI.Count > 0)
            {
                // _____________ PANEL SELECTION TO UPDATE PROPERTIES __________________________________________________________
                if (OVRInput.GetDown(OVRInput.Button.PrimaryThumbstickDown) || Input.GetKeyDown(KeyCode.S))
                {
                    lineNumber++;
                    int linecount = GameObjectHelper.FindNumberOfChildsWithTag(GameObjectHelper.FindGameObjectInChildWithTag(selectablesUI[0], "Values"), "UiLine");
                    if (lineNumber >= linecount)
                    {
                        lineNumber = 0;
                    }

                    foreach (GameObject SelectableUI in selectablesUI)
                    {
                        SelectableUI.GetComponent <Designer>().SetLineNumber(lineNumber);
                        SelectableUI.GetComponent <Designer>().ModifyCanva();
                    }
                }

                if (OVRInput.GetDown(OVRInput.Button.PrimaryThumbstickUp) || Input.GetKeyDown(KeyCode.Z))
                {
                    lineNumber--;
                    int linecount = GameObjectHelper.FindNumberOfChildsWithTag(GameObjectHelper.FindGameObjectInChildWithTag(selectablesUI[0], "Values"), "UiLine");
                    if (lineNumber < 0)
                    {
                        var val = linecount - 1;
                        lineNumber = (val >= 0) ? val : 0;
                    }

                    foreach (GameObject SelectableUI in selectablesUI)
                    {
                        SelectableUI.GetComponent <Designer>().SetLineNumber(lineNumber);
                        SelectableUI.GetComponent <Designer>().ModifyCanva();
                    }
                }

                // upgrade/downgrade caracteristics of the object
                if (OVRInput.GetDown(OVRInput.Button.PrimaryThumbstickLeft) || Input.GetKeyDown(KeyCode.Q))
                {
                    downgradeItem();
                }
                if (OVRInput.GetDown(OVRInput.Button.PrimaryThumbstickRight) || Input.GetKeyDown(KeyCode.D))
                {
                    upgradeItem();
                }
            }
        }
Example #3
0
        /// <summary>
        /// add a line to the canva
        /// </summary>
        /// <param name="txt">the txt that will appear in the line of the canva</param>
        /// <param name="C">the canva getting updated</param>
        private void AddLine(string txt, Canvas C, int deletedItems)
        {
            GameObject    parent    = C.gameObject;
            int           linecount = GameObjectHelper.FindNumberOfChildsWithTag(parent, "UiLine-Empty") + GameObjectHelper.FindNumberOfChildsWithTag(parent, "UiLine") - deletedItems;
            GameObject    newButton = (GameObject)Instantiate(Resources.Load("MesPrefabs/UiLine"), new Vector3(0, -linecount * spacing, 0), Quaternion.identity);
            RectTransform rt        = newButton.GetComponent <RectTransform>();

            rt.sizeDelta = new Vector2(widthButton, heightButton);
            newButton.transform.SetParent(C.transform, false);


            newButton.GetComponentInChildren <TMP_Text>().text     = txt;
            newButton.GetComponentInChildren <TMP_Text>().fontSize = tailleCaracteres;
            newButton.GetComponentInChildren <TMP_Text>().color    = Color.red;

            newButton.tag = txt == "" ? "UiLine-Empty" : "UiLine";//*/
        }