private void ShowEdiorButtonGUI() { GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.FlexibleSpace(); bool selectedInParticleSystemWindow = this.selectedInParticleSystemWindow; GameObject gameObject = (base.target as ParticleSystem).gameObject; GUIContent hideWindowText = null; ParticleSystemWindow instance = ParticleSystemWindow.GetInstance(); if (((instance != null) && instance.IsVisible()) && selectedInParticleSystemWindow) { if (instance.GetNumTabs() > 1) { hideWindowText = this.hideWindowText; } else { hideWindowText = this.closeWindowText; } } else { hideWindowText = this.showWindowText; } GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(110f) }; if (GUILayout.Button(hideWindowText, EditorStyles.miniButton, options)) { if (((instance != null) && instance.IsVisible()) && selectedInParticleSystemWindow) { if (!instance.ShowNextTabIfPossible()) { instance.Close(); } } else { if (!selectedInParticleSystemWindow) { ParticleSystemEditorUtils.lockedParticleSystem = null; Selection.activeGameObject = gameObject; } if (instance != null) { if (!selectedInParticleSystemWindow) { instance.Clear(); } instance.Focus(); } else { this.Clear(); ParticleSystemWindow.CreateWindow(); GUIUtility.ExitGUI(); } } } GUILayout.EndHorizontal(); }
private void ShowEdiorButtonGUI() { GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.FlexibleSpace(); if (this.m_ParticleEffectUI == null || !this.m_ParticleEffectUI.multiEdit) { bool selectedInParticleSystemWindow = this.selectedInParticleSystemWindow; GameObject gameObject = (base.target as ParticleSystem).gameObject; ParticleSystemWindow instance = ParticleSystemWindow.GetInstance(); if (instance) { instance.customEditor = this; } GUIContent content; if (instance && instance.IsVisible() && selectedInParticleSystemWindow) { if (instance.GetNumTabs() > 1) { content = this.hideWindowText; } else { content = this.closeWindowText; } } else { content = this.showWindowText; } if (GUILayout.Button(content, EditorStyles.miniButton, new GUILayoutOption[] { GUILayout.Width(110f) })) { if (instance && instance.IsVisible() && selectedInParticleSystemWindow) { if (!instance.ShowNextTabIfPossible()) { instance.Close(); } } else { if (!selectedInParticleSystemWindow) { ParticleSystemEditorUtils.lockedParticleSystem = null; Selection.activeGameObject = gameObject; } if (instance) { if (!selectedInParticleSystemWindow) { instance.Clear(); } instance.Focus(); } else { this.Clear(); ParticleSystemWindow.CreateWindow(); instance = ParticleSystemWindow.GetInstance(); instance.customEditor = this; GUIUtility.ExitGUI(); } } } } GUILayout.EndHorizontal(); }
void ShowEdiorButtonGUI() { GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); if (m_ParticleEffectUI == null || !m_ParticleEffectUI.multiEdit) { bool alreadySelected = selectedInParticleSystemWindow; GameObject targetGameObject = (target as ParticleSystem).gameObject; GUIContent text = null; ParticleSystemWindow window = ParticleSystemWindow.GetInstance(); if (window) { window.customEditor = this; // window can be created by LoadWindowLayout, when Editor starts up, so always make sure the custom editor member is set up (case 930005) } if (window && window.IsVisible() && alreadySelected) { if (window.GetNumTabs() > 1) { text = hideWindowText; } else { text = closeWindowText; } } else { text = showWindowText; } if (GUILayout.Button(text, EditorStyles.miniButton, GUILayout.Width(110))) { if (window && window.IsVisible() && alreadySelected) { // Hide window (close instead if not possible) if (!window.ShowNextTabIfPossible()) { window.Close(); } } else { if (!alreadySelected) { ParticleSystemEditorUtils.lockedParticleSystem = null; Selection.activeGameObject = targetGameObject; } if (window) { if (!alreadySelected) { window.Clear(); } // Show window window.Focus(); } else { // Kill inspector gui first to ensure playback time is cached properly Clear(); // Create new window ParticleSystemWindow.CreateWindow(); window = ParticleSystemWindow.GetInstance(); window.customEditor = this; GUIUtility.ExitGUI(); } } } } } GUILayout.EndHorizontal(); }
void ShowEditorButtonGUI() { using (new GUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); if (m_ParticleEffectUI != null) { m_ParticleEffectUI.m_SubEmitterSelected = false; } if (m_ParticleEffectUI == null || !m_ParticleEffectUI.multiEdit) { bool alreadySelected = selectedInParticleSystemWindow; GameObject targetGameObject = (target as ParticleSystem).gameObject; // Show a button to select the sub-emitter owner, if this system is a sub-emitter List <ParticleSystem> owners = new List <ParticleSystem>(); var parent = targetGameObject.transform.parent; while (parent != null) { var ps = parent.GetComponent <ParticleSystem>(); if (ps != null) { var subEmitters = ps.subEmitters; if (subEmitters.enabled) { for (int i = 0; i < subEmitters.subEmittersCount; i++) { var subEmitter = subEmitters.GetSubEmitterSystem(i); if (subEmitter != null && subEmitter.gameObject == targetGameObject) { owners.Add(ps); break; } } } } parent = parent.parent; } if (owners.Count > 0) { if (m_ParticleEffectUI != null) { m_ParticleEffectUI.m_SubEmitterSelected = true; } if (owners.Count == 1) { if (GUILayout.Button(GUIContent.Temp(selectSubEmitterOwner.text, owners[0].name), EditorStyles.miniButton, GUILayout.Width(160))) { Selection.activeGameObject = owners[0].gameObject; } } else { if (EditorGUILayout.DropdownButton(selectSubEmitterOwner, FocusType.Passive, EditorStyles.miniButton, GUILayout.Width(160))) { GenericMenu menu = new GenericMenu(); foreach (var owner in owners) { menu.AddItem(new GUIContent(owner.name), false, OnOwnerSelected, owner); } menu.AddSeparator(""); menu.AddItem(new GUIContent("Select All"), false, OnOwnersSelected, owners); Rect buttonRect = GUILayoutUtility.topLevel.GetLast(); menu.DropDown(buttonRect); } } } // When editing a preset the GameObject will have the NotEditable flag. // We do not support the ParticleSystemWindow for Presets for two reasons: // - When selected the Preset editor creates a temporary GameObject which it then uses to edit the properties. // The ParticleSystemWindow also uses the Selection system which triggers a selection change, the Preset // editor cleans up the temp object and the ParticleSystemWindow is now unable to edit the system. // - A preset will only contain a single system, so there is no benefit to using the window. (case 1198545) if ((targetGameObject.hideFlags & HideFlags.NotEditable) != 0) { return; } GUIContent text = null; ParticleSystemWindow window = ParticleSystemWindow.GetInstance(); if (window) { window.customEditor = this; // window can be created by LoadWindowLayout, when Editor starts up, so always make sure the custom editor member is set up (case 930005) } if (window && window.IsVisible() && alreadySelected) { if (window.GetNumTabs() > 1) { text = hideWindowText; } else { text = closeWindowText; } } else { text = showWindowText; } if (GUILayout.Button(text, EditorStyles.miniButton, GUILayout.Width(110))) { if (window && window.IsVisible() && alreadySelected) { // Hide window (close instead if not possible) if (!window.ShowNextTabIfPossible()) { window.Close(); } } else { if (!alreadySelected) { ParticleSystemEditorUtils.lockedParticleSystem = null; Selection.activeGameObject = targetGameObject; } if (window) { if (!alreadySelected) { window.Clear(); } // Show window window.Focus(); } else { // Kill inspector gui first to ensure playback time is cached properly Clear(); // Create new window ParticleSystemWindow.CreateWindow(); window = ParticleSystemWindow.GetInstance(); window.customEditor = this; GUIUtility.ExitGUI(); } } } } } }