Beispiel #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");
                }
            }
        }
Beispiel #2
0
 protected void OnEnable()
 {
     BloxContainerInspector.Instance = this;
     this.Target = (BloxContainer)base.target;
     if ((UnityEngine.Object) this.Target.bloxGlobalPrefab != (UnityEngine.Object)BloxEd.BloxGlobalPrefab)
     {
         this.Target.bloxGlobalPrefab = BloxEd.BloxGlobalPrefab;
         this.Save();
     }
     this.CacheBloxList(null, null);
     plyReorderableList.Button[] extraButtons = new plyReorderableList.Button[3]
     {
         new plyReorderableList.Button
         {
             label    = new GUIContent(Ico._settings, "Open Blox settings"),
             callback = BloxSettingsWindow.Show_BloxSettingsWindow
         },
         new plyReorderableList.Button
         {
             label           = new GUIContent(Ico._blox + "Edit", "Edit selected Blox"),
             callback        = this.OnDoubleClick,
             requireSelected = true
         },
         new plyReorderableList.Button
         {
             label           = new GUIContent(Ico._rename, "Rename selected Blox"),
             callback        = this.OnRenameBlox,
             requireSelected = true
         }
     };
     plyReorderableList.Button[] addOptions = new plyReorderableList.Button[2]
     {
         new plyReorderableList.Button
         {
             label    = new GUIContent("Create new"),
             callback = this.AddNewBloxDef
         },
         new plyReorderableList.Button
         {
             label    = new GUIContent("Add Existing"),
             callback = this.AddExistingBloxDef
         }
     };
     this.list = new plyReorderableList(this.targetBloxCache, typeof(Blox), true, true, true, true, false, false, false, extraButtons, addOptions);
     this.list.elementHeight        = (float)(EditorGUIUtility.singleLineHeight + 2.0 + 4.0);
     this.list.drawHeaderCallback   = this.DrawListHeader;
     this.list.drawElementCallback  = this.DrawListElement;
     this.list.onSelectElement      = this.OnSelectBlox;
     this.list.onDoubleClickElement = this.OnDoubleClick;
     this.list.onRemoveElement      = this.OnRemove;
     this.list.onReorder            = this.OnReorder;
     this.varEditor         = new plyVariablesEditor(null, plyVariablesType.Blox, this.Target.gameObject, true, false, true, this.Repaint, this.Save, null);
     this.varEditor.GC_Head = BloxContainerInspector.GC_VarsHead;
     if (this.targetBloxCache.Count > 0)
     {
         this.list.index = 0;
         this.OnSelectBlox();
     }
 }
Beispiel #3
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();
 }
Beispiel #4
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();
        }
Beispiel #5
0
 protected void OnDisable()
 {
     BloxContainerInspector.Instance = null;
     this.Target = null;
     this.targetBloxCache.Clear();
 }