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(); } }
public plyVariablesEditor(plyVariables variables, plyVariablesType varsType, GameObject variablesOwner, bool canEditValues, bool canEditVariables, bool displayHeader, Action repaint, Action save, plyReorderableList.Button[] extraButtons) { plyVariablesEditor.LoadVarEds(); this.variables = variables; this.varsType = varsType; this.variablesOwner = variablesOwner; this.isOnSceneObject = (!((UnityEngine.Object)variablesOwner == (UnityEngine.Object)null) && plyEdUtil.IsSceneObject(variablesOwner)); this.canEditValues = canEditValues; this.canEditVariables = canEditVariables; this.repaint = repaint; this.save = save; if (extraButtons == null) { extraButtons = new plyReorderableList.Button[0]; } if (canEditVariables) { ArrayUtility.Add(ref extraButtons, new plyReorderableList.Button { label = new GUIContent(Ico._rename, "Rename selected Variable"), callback = this.OnRenameButton, requireSelected = true }); } if (canEditVariables) { this.varsList = new plyReorderableList((variables != null) ? variables.varDefs : null, typeof(plyVar), false, true, true, true, false, false, extraButtons, null); this.varsList.elementHeight = (float)((float)((!canEditValues) ? 1 : 2) * (EditorGUIUtility.singleLineHeight + 2.0) + 4.0); this.varsList.drawHeaderCallback = this.DrawListHeader; this.varsList.drawElementCallback = this.DrawElement; this.varsList.onAddElement = this.OnAdd; this.varsList.onRemoveElement = this.OnRemove; this.varsList.onReorder = null; } else { this.varsList = new plyReorderableList((variables != null) ? variables.varDefs : null, typeof(plyVar), false, displayHeader, false, false, false, false, extraButtons, null); this.varsList.elementHeight = (float)((float)((!canEditValues) ? 1 : 2) * (EditorGUIUtility.singleLineHeight + 2.0) + 4.0); if (displayHeader) { this.varsList.drawHeaderCallback = this.DrawListHeader; } this.varsList.drawElementCallback = this.DrawElement; this.varsList.onAddElement = null; this.varsList.onRemoveElement = null; this.varsList.onReorder = null; } }