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 override void OnInspectorGUI() { base.OnInspectorGUI(); this.Target = (BloxContainer)base.target; EditorGUILayout.Space(); this.list.DoLayoutList(); if (this.activeVars != null) { this.varEditor.DoLayout(); } if (this.deletedDetected && Event.current.type == EventType.Repaint) { this.deletedDetected = false; this.CacheBloxList(null, null); } Event current = Event.current; switch (current.type) { case EventType.DragExited: this.dragDropBlox = null; current.Use(); break; case EventType.DragPerform: if ((UnityEngine.Object) this.dragDropBlox != (UnityEngine.Object)null) { DragAndDrop.AcceptDrag(); plyEdGUI.ClearFocus(); current.Use(); if (!this.Target.bloxIdents.Contains(this.dragDropBlox.ident)) { if (!this.targetBloxCache.Contains(this.dragDropBlox)) { this.targetBloxCache.Add(this.dragDropBlox); } this.Target.bloxIdents.Add(this.dragDropBlox.ident); this.Save(); } this.dragDropBlox = null; } break; case EventType.DragUpdated: this.dragDropBlox = (DragAndDrop.GetGenericData("BloxDefinition") as Blox); if ((UnityEngine.Object) this.dragDropBlox != (UnityEngine.Object)null) { DragAndDrop.visualMode = DragAndDropVisualMode.Move; current.Use(); } else { DragAndDrop.visualMode = DragAndDropVisualMode.Rejected; } break; } }
private void CacheVariable() { if (Application.isPlaying && (this.v == null || !((UnityEngine.Object) this.sourceObj != (UnityEngine.Object)null))) { if (this.varType == VariableType.Global) { this.sourceObj = GlobalVariables.Instance; this.v = GlobalVariables.Instance.variables.FindVariable(this.varName); if (this.v == null) { Debug.LogErrorFormat("The Global Variable [{0}] does not exist.", this.varName); } else if (!base.isSetter) { this.v.onValueChange += this.BoundValueChanged; } } else if (this.varType == VariableType.Blox) { BloxContainer bloxContainer = this.CacheSourceObject() as BloxContainer; if (!((UnityEngine.Object)bloxContainer == (UnityEngine.Object)null)) { if (!string.IsNullOrEmpty(this.triggerBloxEvent)) { bloxContainer.TriggerEvent(this.triggerBloxEvent); } this.v = bloxContainer.FindVariable(this.bloxIdent, this.varName); if (this.v == null) { Blox blox = BloxGlobal.Instance.FindBloxDef(this.bloxIdent); Debug.LogErrorFormat("The Blox Variable [{0}] does not exist in Blox [{1}] on GameObject [{2}]", this.varName, ((object)blox != null) ? blox.screenName : null, bloxContainer.name); } else if (!base.isSetter) { this.v.onValueChange += this.BoundValueChanged; } } } else if (this.varType == VariableType.Object) { ObjectVariables objectVariables = this.CacheSourceObject() as ObjectVariables; if (!((UnityEngine.Object)objectVariables == (UnityEngine.Object)null)) { this.v = objectVariables.FindVariable(this.varName); if (this.v == null) { Debug.LogErrorFormat("The Object Variable [{0}] does not exist on GameObject [{1}]", this.varName, objectVariables.name); } else if (!base.isSetter) { this.v.onValueChange += this.BoundValueChanged; } } } } }
public static void Show_BloxListPopup(BloxContainer target, Action onAddCallback) { BloxListPopup window = EditorWindow.GetWindow <BloxListPopup>(true, "Blox Definitions", true); Texture2D image = plyEdGUI.LoadTextureResource("BloxEditor.res.icons.blox_mono" + (EditorGUIUtility.isProSkin ? "_p" : "") + ".png", typeof(BloxListWindow).Assembly, FilterMode.Point, TextureWrapMode.Clamp); window.titleContent = new GUIContent("Blox Definitions", image); window.target = target; window.onAddCallback = onAddCallback; window.minSize = new Vector2(200f, 250f); window.ShowUtility(); }
private void CacheBloxContainer() { if (!((UnityEngine.Object) this.bloxContainer != (UnityEngine.Object)null)) { if (this.sourceObjType == DataSourceOject.WithName) { GameObject gameObject = GameObject.Find(this.objNameOrTag); this.bloxContainer = (((object)gameObject != null) ? gameObject.GetComponent <BloxContainer>() : null); if ((UnityEngine.Object) this.bloxContainer == (UnityEngine.Object)null) { Debug.LogError("[TriggerEvent DataProvider] The Blox Container could not be found on: " + this.objNameOrTag); } } else if (this.sourceObjType == DataSourceOject.WithTag) { GameObject gameObject2 = GameObject.FindGameObjectWithTag(this.objNameOrTag); this.bloxContainer = (((object)gameObject2 != null) ? gameObject2.GetComponent <BloxContainer>() : null); if ((UnityEngine.Object) this.bloxContainer == (UnityEngine.Object)null) { Debug.LogError("[TriggerEvent DataProvider] The Blox Container could not be found on GameObject with tag: " + this.objNameOrTag); } } else if (this.sourceObjType == DataSourceOject.Owner) { Component owner = base.owner; this.bloxContainer = (((object)owner != null) ? owner.GetComponent <BloxContainer>() : null); if ((UnityEngine.Object) this.bloxContainer == (UnityEngine.Object)null) { Debug.LogError("[TriggerEvent DataProvider] The Blox Container could not be found on GameObject or 'owner' was not a valid context for the object source."); } } else { Debug.LogErrorFormat("[TriggerEvent DataProvider] The Blox Container could not be found."); } } }
protected void OnDisable() { BloxContainerInspector.Instance = null; this.Target = null; this.targetBloxCache.Clear(); }
protected void OnDisable() { this.Target = null; this.targetBloxCache.Clear(); }