Example #1
0
        private void CreateVariable(plyVarCreateWiz wiz)
        {
            plyVar var = wiz.var;

            wiz.Close();
            this.varEditor.VariableWasAdded();
            if (!string.IsNullOrEmpty(var.name))
            {
                if (plyEdUtil.StringIsUnique(this.blox.variables.varDefs, var.name))
                {
                    var.ident = this.blox.variables.CreateVariableIdent();
                    this.blox.variables.varDefs.Add(var);
                    this.Save();
                    BloxContainerInspector instance = BloxContainerInspector.Instance;
                    if ((object)instance != null)
                    {
                        instance.OnBloxVariablesChanged(this.blox.ident);
                    }
                }
                else
                {
                    EditorUtility.DisplayDialog("Variables", "The variable name must be unique.", "OK");
                }
            }
        }
Example #2
0
 private void DoBloxVariablesToolbar()
 {
     if ((UnityEngine.Object)BloxEditorWindow.Instance != (UnityEngine.Object)null && (UnityEngine.Object)BloxEditorWindow.Instance.blox != (UnityEngine.Object)null)
     {
         if ((UnityEngine.Object) this.blox != (UnityEngine.Object)BloxEditorWindow.Instance.blox)
         {
             this.blox = BloxEditorWindow.Instance.blox;
             this.varEditor.SetTarget(this.blox.variables, null);
         }
     }
     else if ((UnityEngine.Object) this.blox != (UnityEngine.Object)null)
     {
         this.blox = null;
         this.varEditor.SetTarget(null, null);
     }
     this.selected = this.varEditor.SelectedIdx;
     GUILayout.Label(BloxBlocksList.GC_VarsHeading);
     GUI.enabled = ((UnityEngine.Object) this.blox != (UnityEngine.Object)null);
     if (GUILayout.Button(BloxBlocksList.GC_ListButtons[0], plyEdGUI.Styles.ToolbarButton))
     {
         plyVarCreateWiz.ShowWiz(this.CreateVariable, "Variable", null);
     }
     GUI.enabled = (this.selected >= 0 && (UnityEngine.Object) this.blox != (UnityEngine.Object)null);
     if (GUILayout.Button(BloxBlocksList.GC_ListButtons[1], plyEdGUI.Styles.ToolbarButton) && EditorUtility.DisplayDialog("Blox Variables", "Removing the Variable can't be undone. Are you sure?", "Yes", "Cancel"))
     {
         this.blox.variables.varDefs.RemoveAt(this.selected);
         this.selected--;
         if (this.selected <= -1)
         {
             this.selected = ((this.blox.variables.varDefs.Count <= 0) ? (-1) : 0);
         }
         this.Save();
         BloxContainerInspector instance = BloxContainerInspector.Instance;
         if ((object)instance != null)
         {
             instance.OnBloxVariablesChanged(this.blox.ident);
         }
     }
     GUI.enabled = (this.selected >= 0 && (UnityEngine.Object) this.blox != (UnityEngine.Object)null);
     if (GUILayout.Button(BloxBlocksList.GC_ListButtons[2], plyEdGUI.Styles.ToolbarButton))
     {
         plyTextInputWiz.ShowWiz("Rename Variable", "Enter a unique name", this.blox.variables.varDefs[this.selected].name, this.OnRenameVariable, null, 250f);
     }
     GUI.enabled = true;
     GUILayout.FlexibleSpace();
 }
Example #3
0
        private void OnRenameVariable(plyTextInputWiz wiz)
        {
            string text = wiz.text;

            wiz.Close();
            if (!string.IsNullOrEmpty(text) && !text.Equals(this.blox.variables.varDefs[this.selected].name))
            {
                if (plyEdUtil.StringIsUnique(this.blox.variables.varDefs, text))
                {
                    this.blox.variables.varDefs[this.selected].name = text;
                    this.Save();
                    BloxContainerInspector instance = BloxContainerInspector.Instance;
                    if ((object)instance != null)
                    {
                        instance.OnBloxVariablesChanged(this.blox.ident);
                    }
                }
                else
                {
                    EditorUtility.DisplayDialog("Variables", "The variable name must be unique.", "OK");
                }
            }
            this.ed.Repaint();
        }