private void GenerateInternalEditor() { UnityEngine.Object[] array = new UnityEngine.Object[base.targets.Length]; for (int i = 0; i < base.targets.Length; i++) { Preset preset = (Preset)base.targets[i]; PresetEditor.ReferenceCount referenceCount = null; if (!PresetEditor.s_References.TryGetValue(preset.GetInstanceID(), out referenceCount)) { referenceCount = new PresetEditor.ReferenceCount { count = 0, reference = preset.GetReferenceObject() }; if (referenceCount.reference == null) { this.m_NotSupportedEditorName = preset.GetTargetTypeName(); return; } PresetEditor.s_References.Add(preset.GetInstanceID(), referenceCount); } referenceCount.count++; array[i] = referenceCount.reference; } this.m_InternalEditor = Editor.CreateEditor(array); }
private void DestroyInternalEditor() { if (this.m_InternalEditor != null) { UnityEngine.Object.DestroyImmediate(this.m_InternalEditor); for (int i = 0; i < base.targets.Length; i++) { Preset preset = (Preset)base.targets[i]; if (--PresetEditor.s_References[preset.GetInstanceID()].count == 0) { if (PresetEditor.s_References[preset.GetInstanceID()].reference is Component) { GameObject gameObject = ((Component)PresetEditor.s_References[preset.GetInstanceID()].reference).gameObject; UnityEngine.Object.DestroyImmediate(gameObject); } else { UnityEngine.Object.DestroyImmediate(PresetEditor.s_References[preset.GetInstanceID()].reference); } PresetEditor.s_References.Remove(preset.GetInstanceID()); } } } }
void Init(PresetType presetType, Preset currentSelection, bool createNewAllowed, PresetSelectorReceiver eventReceiver) { AssemblyReloadEvents.beforeAssemblyReload -= OnBeforeAssemblyReload; AssemblyReloadEvents.beforeAssemblyReload += OnBeforeAssemblyReload; m_ModalUndoGroup = Undo.GetCurrentGroup(); // Freeze to prevent flicker on OSX. // Screen will be updated again when calling // SetFreezeDisplay(false) further down. ContainerWindow.SetFreezeDisplay(true); // Set member variables m_SearchField = string.Empty; m_CanCreateNew = createNewAllowed; InitListArea(); m_Presets = FindAllPresetsOfType(presetType); UpdateSearchResult(currentSelection != null ? currentSelection.GetInstanceID() : 0); m_EventObject = eventReceiver; ShowWithMode(ShowMode.AuxWindow); titleContent = EditorGUIUtility.TrTextContent("Select Preset"); // Deal with window size Rect rect = m_Parent.window.position; rect.width = EditorPrefs.GetFloat(k_PresetSelectorWidthEditorPref, 200); rect.height = EditorPrefs.GetFloat(k_PresetSelectorHeightEditorPref, 200); position = rect; minSize = new Vector2(kMinWidth, kMinTopSize + kPreviewExpandedAreaHeight + 2 * kPreviewMargin); maxSize = new Vector2(500, 600); // Focus Focus(); ContainerWindow.SetFreezeDisplay(false); // Add after unfreezing display because AuxWindowManager.cpp assumes that aux windows are added after we get 'got/lost'- focus calls. m_Parent.AddToAuxWindowList(); SetSelectedPath(GetCurrentSelection()); }
private void Init(UnityEngine.Object target, Preset currentSelection, bool createNewAllowed, PresetSelectorReceiver eventReceiver) { this.m_ModalUndoGroup = Undo.GetCurrentGroup(); ContainerWindow.SetFreezeDisplay(true); this.m_SearchField = string.Empty; this.m_MainTarget = target; this.InitListArea(); this.m_Presets = PresetSelector.FindAllPresetsForObject(target); this.UpdateSearchResult((!(currentSelection != null)) ? 0 : currentSelection.GetInstanceID()); this.m_EventObject = eventReceiver; this.m_CanCreateNew = createNewAllowed; base.ShowWithMode(ShowMode.AuxWindow); base.titleContent = EditorGUIUtility.TrTextContent("Select Preset", null, null); Rect position = this.m_Parent.window.position; position.width = EditorPrefs.GetFloat("PresetSelectorWidth", 200f); position.height = EditorPrefs.GetFloat("PresetSelectorHeight", 390f); base.position = position; base.minSize = new Vector2(200f, 335f); base.maxSize = new Vector2(10000f, 10000f); base.Focus(); ContainerWindow.SetFreezeDisplay(false); this.m_Parent.AddToAuxWindowList(); }