コード例 #1
0
        public void Update()
        {
            IEnterField field = gameObject.GetComponent <IEnterField>();

            field.options      = this.options;
            field.Name         = this.Name;
            field.tab          = this.tab;
            field.VariableName = this.VariableName;
            field.type         = this.type;
            field.CreatorOnly  = this.CreatorOnly;
            this.enabled       = false;
        }
コード例 #2
0
        public void setEdit(Transform obj) //Set an input area to be the selected one to edit
        {
            if (currentEdit != null)       //If an input is selected, then revert it's color
            {
                SaveOptions();
                currentEdit.GetComponent <Image>().color = CurrentColor;
            }
            if (currentEdit == obj || obj == null) //If the new area is already selected, then deselect it
            {
                currentEdit = null;
                UpdateInputs();
                NameInput.text = "";
                SetColourSliders(Color.white);
                OptionsInput.text = "";
                return;
            }

            currentEdit = obj;                                                    //Set to the new edit
            UpdateInputs();                                                       //update sliders and text input

            string VarName = obj.Find("VariableName").GetComponent <Text>().text; //Update the Variable Name Input Field

            if (VarName.EndsWith(":"))
            {
                VarName = VarName.Substring(0, VarName.Length - 1);
            }
            Debug.Log(VarName + " Selected.");

            NameInput.text = VarName;
            SetColourSliders(currentEdit.GetComponent <Image>().color);  //Store previous color
            currentEdit.GetComponent <Image>().color = HighlightedColor; //Set to selected color

            IEnterField inputType = currentEdit.gameObject.GetComponent <IEnterField>();

            string[] optionsTo = inputType.options.ToArray();
            if (optionsTo.Length > 0)
            {
                int colourAt = -1;
                for (int i = 0; i < optionsTo.Length; i++)
                {
                    if (optionsTo[i].Contains(ColourOptionPrefix))
                    {
                        colourAt = i;
                        break;
                    }
                }
                if (colourAt > -1)
                {
                    string ColourHex = optionsTo[colourAt].Substring(ColourOptionPrefix.Length);
                    CurrentColor = ContentManager.HexToColor(ColourHex);
                }
                optionsTo = inputType.GetNonOptions().ToArray();

                if (optionsTo.Length > 0)
                {
                    OptionsInput.text = string.Join("\n", optionsTo);
                }
            }

            //Disable the Variable Name input
            bool dis = false;

            if (currentEdit.GetComponent <scr_NameEnter>() != null)
            {
                dis = true;
            }
            if (currentEdit.GetComponent <scr_VersionEnter>() != null)
            {
                dis = true;
            }

            if (dis)
            {
                NameInput.DeactivateInputField();
            }
            else
            {
                NameInput.ActivateInputField();
            }
        }