/// <summary> /// initializes the canvas inside the UI and add an handler /// </summary> void Start() { Values = GameObjectHelper.FindGameObjectInChildWithTag(gameObject, "Values").GetComponent <Canvas>(); NameOfTheValues = GameObjectHelper.FindGameObjectInChildWithTag(gameObject, "NameOfTheValues").GetComponent <Canvas>(); // Now lets test the event contained in the above class. this.Designing += new MyDesignerHandler(Design); }
/// <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(); } } }
/// <summary> /// get the parameters inside the UI /// </summary> /// <returns>a list of parameters as List<float> </returns> private List <float> GetCurrentParameters() { List <float> param = new List <float>(); List <Transform> lines = GameObjectHelper.GetAllChilds(GameObjectHelper.FindGameObjectInChildWithTag(selectablesUI[0], "Values").GetComponent <Canvas>()); foreach (Transform line in lines) { string value = line.GetComponentInChildren <TMP_Text>().text; int.TryParse(value, out int j); param.Add(j); } return(param); }