private void DoBrushesDropdown() { GUIContent content = GUIContent.Temp(GridPaintingState.gridBrush.name); if (EditorGUILayout.DropdownButton(content, FocusType.Passive, EditorStyles.toolbarPopup, GUILayout.Width(k_DropdownWidth))) { var menuData = new GridBrushesDropdown.MenuItemProvider(); var flexibleMenu = new GridBrushesDropdown(menuData, GridPaletteBrushes.brushes.IndexOf(GridPaintingState.gridBrush), null, SelectBrush, k_DropdownWidth); PopupWindow.Show(GUILayoutUtility.topLevel.GetLast(), flexibleMenu); } }
private void DoBrushesDropdown() { GUIContent content = GUIContent.Temp(GridPaintingState.gridBrush.name); if (EditorGUILayout.DropdownButton(content, FocusType.Passive, EditorStyles.toolbarPopup, new GUILayoutOption[] { GUILayout.Width(200f) })) { GridBrushesDropdown.MenuItemProvider itemProvider = new GridBrushesDropdown.MenuItemProvider(); GridBrushesDropdown windowContent = new GridBrushesDropdown(itemProvider, GridPaletteBrushes.brushes.IndexOf(GridPaintingState.gridBrush), null, new Action <int, object>(this.SelectBrush), 200f); PopupWindow.Show(GUILayoutUtility.topLevel.GetLast(), windowContent); } }
void PrefabFamilyButton() { if (EditorGUILayout.DropdownButton(GUIContent.none, FocusType.Passive, GUILayout.MaxWidth(Styles.kHierarchyIconWidth))) { if (!PrefabFamilyPopup.isOpen) { PopupWindow.Show(GUILayoutUtility.topLevel.GetLast(), new PrefabFamilyPopup((GameObject)assetTarget)); } GUIUtility.ExitGUI(); } var rect = new Rect(GUILayoutUtility.topLevel.GetLast()); rect.x += 6; EditorGUI.LabelField(rect, Styles.hierarchyIcon); }
private void DoActiveTargetsGUI() { bool hasPaintTarget = GridPaintingState.scenePaintTarget != null; using (new EditorGUI.DisabledScope(!hasPaintTarget || GridPaintingState.validTargets == null)) { GUILayout.Label(Styles.activeTargetLabel, GUILayout.Width(k_ActiveTargetLabelWidth)); GUIContent content = GUIContent.Temp(hasPaintTarget ? GridPaintingState.scenePaintTarget.name : "Nothing"); if (EditorGUILayout.DropdownButton(content, FocusType.Passive, EditorStyles.popup, GUILayout.Width(k_ActiveTargetDropdownWidth))) { int index = hasPaintTarget ? Array.IndexOf(GridPaintingState.validTargets, GridPaintingState.scenePaintTarget) : 0; var menuData = new GridPaintTargetsDropdown.MenuItemProvider(); var flexibleMenu = new GridPaintTargetsDropdown(menuData, index, null, SelectTarget, k_ActiveTargetDropdownWidth); PopupWindow.Show(GUILayoutUtility.topLevel.GetLast(), flexibleMenu); } } }
protected override void EndDrawPreviewAndLabels(Event evt, Rect rect, Rect dragRect) { if (m_HasPreview || m_PreviewWindow != null) { if (EditorGUILayout.DropdownButton(Styles.menuIcon, FocusType.Passive, Styles.preOptionsButton)) { GenericMenu menu = new GenericMenu(); menu.AddItem( EditorGUIUtility.TrTextContent(m_PreviewWindow == null ? "Convert to Floating Window" : "Dock Preview to Inspector"), false, () => { if (m_PreviewWindow == null) { DetachPreview(false); } else { m_PreviewWindow.Close(); } }); menu.AddItem( EditorGUIUtility.TrTextContent(m_PreviewResizer.GetExpanded() ? "Minimize in Inspector" : "Restore in Inspector"), false, () => { m_PreviewResizer.SetExpanded(position, k_InspectorPreviewMinTotalHeight, k_MinAreaAbovePreview, kBottomToolbarHeight, dragRect, !m_PreviewResizer.GetExpanded()); }); menu.ShowAsContext(); } } // Detach preview on right click in preview title bar if (evt.type == EventType.MouseUp && evt.button == 1 && rect.Contains(evt.mousePosition) && m_PreviewWindow == null) { DetachPreview(); } }
public void DoPreviewSettings() { Init(); if (m_ShowIKOnFeetButton) { EditorGUI.BeginChangeCheck(); m_IKOnFeet = GUILayout.Toggle(m_IKOnFeet, s_Styles.ik, s_Styles.preButton); if (EditorGUI.EndChangeCheck()) { EditorPrefs.SetBool(kIkPref, m_IKOnFeet); } } EditorGUI.BeginChangeCheck(); GUILayout.Toggle(is2D, s_Styles.is2D, s_Styles.preButton); if (EditorGUI.EndChangeCheck()) { is2D = !is2D; EditorPrefs.SetBool(k2DPref, is2D); } EditorGUI.BeginChangeCheck(); m_ShowReference = GUILayout.Toggle(m_ShowReference, s_Styles.pivot, s_Styles.preButton); if (EditorGUI.EndChangeCheck()) { EditorPrefs.SetBool(kReferencePref, m_ShowReference); } if (EditorGUILayout.DropdownButton(s_Styles.avatarIcon, FocusType.Passive, EditorStyles.toolbarDropDownRight)) { GenericMenu menu = new GenericMenu(); menu.AddItem(EditorGUIUtility.TrTextContent("Auto"), false, SetPreviewAvatarOption, PreviewPopupOptions.Auto); menu.AddItem(EditorGUIUtility.TrTextContent("Unity Model"), false, SetPreviewAvatarOption, PreviewPopupOptions.DefaultModel); menu.AddItem(EditorGUIUtility.TrTextContent("Other..."), false, SetPreviewAvatarOption, PreviewPopupOptions.Other); menu.ShowAsContext(); } }
private void DoActiveTargetsGUI() { bool flag = GridPaintingState.scenePaintTarget != null; using (new EditorGUI.DisabledScope(!flag || GridPaintingState.validTargets == null)) { GUILayout.Label(GridPaintPaletteWindow.Styles.activeTargetLabel, new GUILayoutOption[] { GUILayout.Width(90f) }); GUIContent content = GUIContent.Temp((!flag) ? "Nothing" : GridPaintingState.scenePaintTarget.name); if (EditorGUILayout.DropdownButton(content, FocusType.Passive, EditorStyles.popup, new GUILayoutOption[] { GUILayout.Width(130f) })) { int selectionIndex = (!flag) ? 0 : Array.IndexOf <GameObject>(GridPaintingState.validTargets, GridPaintingState.scenePaintTarget); GridPaintTargetsDropdown.MenuItemProvider itemProvider = new GridPaintTargetsDropdown.MenuItemProvider(); GridPaintTargetsDropdown windowContent = new GridPaintTargetsDropdown(itemProvider, selectionIndex, null, new Action <int, object>(this.SelectTarget), 130f); PopupWindow.Show(GUILayoutUtility.topLevel.GetLast(), windowContent); } } }
public void OnGUI(AudioMixerGroupController group) { if (!(group == null)) { AudioMixerController controller = group.controller; List <AudioMixerGroupController> allAudioGroupsSlow = controller.GetAllAudioGroupsSlow(); Dictionary <AudioMixerEffectController, AudioMixerGroupController> dictionary = new Dictionary <AudioMixerEffectController, AudioMixerGroupController>(); foreach (AudioMixerGroupController current in allAudioGroupsSlow) { AudioMixerEffectController[] effects = current.effects; for (int i = 0; i < effects.Length; i++) { AudioMixerEffectController key = effects[i]; dictionary[key] = current; } } Rect totalRect = EditorGUILayout.BeginVertical(new GUILayoutOption[0]); if (EditorApplication.isPlaying) { GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.FlexibleSpace(); EditorGUI.BeginChangeCheck(); GUILayout.Toggle(AudioSettings.editingInPlaymode, AudioMixerEffectView.Texts.editInPlaymode, EditorStyles.miniButton, new GUILayoutOption[] { GUILayout.Width(120f) }); if (EditorGUI.EndChangeCheck()) { AudioSettings.editingInPlaymode = !AudioSettings.editingInPlaymode; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } using (new EditorGUI.DisabledScope(!AudioMixerController.EditingTargetSnapshot())) { if (group != this.m_PrevGroup) { this.m_PrevGroup = group; controller.m_HighlightEffectIndex = -1; AudioMixerUtility.RepaintAudioMixerAndInspectors(); } AudioMixerEffectView.DoInitialModule(group, controller, allAudioGroupsSlow); for (int j = 0; j < group.effects.Length; j++) { this.DoEffectGUI(j, group, allAudioGroupsSlow, dictionary, ref controller.m_HighlightEffectIndex); } this.m_EffectDragging.HandleDragging(totalRect, group, controller); GUILayout.Space(10f); EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayout.FlexibleSpace(); if (EditorGUILayout.DropdownButton(AudioMixerEffectView.Texts.addEffect, FocusType.Passive, GUISkin.current.button, new GUILayoutOption[0])) { GenericMenu genericMenu = new GenericMenu(); Rect last = GUILayoutUtility.topLevel.GetLast(); AudioMixerGroupController[] groups = new AudioMixerGroupController[] { group }; AudioMixerChannelStripView.AddEffectItemsToMenu(controller, groups, group.effects.Length, string.Empty, genericMenu); genericMenu.DropDown(last); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); } }
public void OnGUI(AudioMixerGroupController group) { if (group == null) { return; } var controller = group.controller; var allGroups = controller.GetAllAudioGroupsSlow(); var effectMap = new Dictionary <AudioMixerEffectController, AudioMixerGroupController>(); foreach (var g in allGroups) { foreach (var e in g.effects) { effectMap[e] = g; } } Rect totalRect = EditorGUILayout.BeginVertical(); if (EditorApplication.isPlaying) { GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); EditorGUI.BeginChangeCheck(); GUILayout.Toggle(AudioSettings.editingInPlaymode, Texts.editInPlaymode, EditorStyles.miniButton, GUILayout.Width(120)); if (EditorGUI.EndChangeCheck()) { AudioSettings.editingInPlaymode = !AudioSettings.editingInPlaymode; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); } using (new EditorGUI.DisabledScope(!AudioMixerController.EditingTargetSnapshot())) { if (group != m_PrevGroup) { m_PrevGroup = group; controller.m_HighlightEffectIndex = -1; AudioMixerUtility.RepaintAudioMixerAndInspectors(); } // Do Effect modules DoInitialModule(group, controller, allGroups); for (int effectIndex = 0; effectIndex < group.effects.Length; effectIndex++) { DoEffectGUI(effectIndex, group, allGroups, effectMap, ref controller.m_HighlightEffectIndex); } m_EffectDragging.HandleDragging(totalRect, group, controller); GUILayout.Space(10f); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (EditorGUILayout.DropdownButton(Texts.addEffect, FocusType.Passive, GUISkin.current.button)) { GenericMenu pm = new GenericMenu(); Rect buttonRect = GUILayoutUtility.topLevel.GetLast(); AudioMixerGroupController[] groupArray = new AudioMixerGroupController[] { group }; AudioMixerChannelStripView.AddEffectItemsToMenu(controller, groupArray, group.effects.Length, string.Empty, pm); pm.DropDown(buttonRect); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); }
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(); } } } } } }
void OnGUI() { EditorGUILayout.BeginHorizontal(); Rect dropdownbuttonRect = new Rect(0, 0, 70, 20); var _contentRect = contentRect; _contentRect.height = (zoo.animals.Count + 1) * 20; EditorGUI.DrawRect(zoneRect, new Color(0.2f, 0.2f, 0.2f)); //GUILayout.BeginArea(zoneRect, GUI.skin.box); sp = GUI.BeginScrollView(zoneRect, sp, _contentRect); //GUI.Label(new Rect(100, 200, Screen.width, 50), "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); GUILayout.BeginArea(_contentRect); EditorGUILayout.LabelField("animal count", zoo.animals.Count.ToString()); for (int i = 0; i < zoo.animals.Count; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(i.ToString(), zoo.animals[i].Species); if (EditorGUILayout.DropdownButton(new GUIContent(m_Type[zoo.animals[i].type]), FocusType.Passive)) { GenericMenu menu = new GenericMenu(); for (int j = 0; j < m_Type.Length; j++) { var info = new ClickInfo { index = i, type = j }; menu.AddItem(new GUIContent(m_Type[j]), false, ItemCallBack2, info); } //menu.DropDown(GUILayoutUtility.GetLastRect()); menu.ShowAsContext(); } if (GUILayout.Button("remove", GUILayout.Width(70))) { zoo.animals.RemoveAt(i); } EditorGUILayout.EndHorizontal(); } GUILayout.EndArea(); GUI.EndScrollView(); EditorGUILayout.EndHorizontal(); //GUILayout.EndArea(); GUILayout.BeginArea(buttonRect, GUI.skin.box); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("add Cat")) { zoo.animals.Add(new Cat()); } if (GUILayout.Button("add Dog")) { zoo.animals.Add(new Dog()); } if (GUILayout.Button("add Giraffe")) { zoo.animals.Add(new Giraffe()); } EditorGUILayout.EndHorizontal(); GUILayout.EndArea(); GUILayout.BeginArea(dropdownButtonRect, GUI.skin.box); EditorGUILayout.BeginHorizontal(); if (EditorGUILayout.DropdownButton(new GUIContent(m_Type[selectedType]), FocusType.Passive)) { GenericMenu menu = new GenericMenu(); for (int i = 0; i < m_Type.Length; i++) { menu.AddItem(new GUIContent(m_Type[i]), false, ItemCallBack, i); } menu.ShowAsContext(); } //GUILayout.FlexibleSpace(); this.selectedOption = EditorGUILayout.Popup("Popup", (int)this.selectedOption, new string[] { "s1", "s2", "s3" }); if (GUILayout.Button("Select Animation")) { AnimationClip fbxObj = AssetDatabase.LoadAssetAtPath <AnimationClip>("Assets/Data/Emotes--RussianDance.anim.fbx"); Selection.activeObject = fbxObj; } //Set certain model to the AvatarPreview window if (GUILayout.Button("Set Model")) { SetSelectModel("Assets/Data/Robot_A.fbx"); } EditorGUILayout.EndHorizontal(); GUILayout.EndArea(); }