private void OnDisable() { PopupWindowWithoutFocus.s_LastClosedTime = EditorApplication.timeSinceStartup; if (this.m_WindowContent != null) this.m_WindowContent.OnClose(); PopupWindowWithoutFocus.s_PopupWindowWithoutFocus = (PopupWindowWithoutFocus) null; }
internal static void Show(Rect activatorRect, PopupWindowContent windowContent, PopupLocationHelper.PopupLocation[] locationPriorityOrder) { if (!PopupWindowWithoutFocus.ShouldShowWindow(activatorRect)) return; if ((Object) PopupWindowWithoutFocus.s_PopupWindowWithoutFocus == (Object) null) PopupWindowWithoutFocus.s_PopupWindowWithoutFocus = ScriptableObject.CreateInstance<PopupWindowWithoutFocus>(); PopupWindowWithoutFocus.s_PopupWindowWithoutFocus.Init(activatorRect, windowContent, locationPriorityOrder); }
private void BottomArea() { GUILayout.BeginVertical(PackageImport.ms_Constants.bottomBarBg, new GUILayoutOption[0]); GUILayout.Space(8f); GUILayout.BeginHorizontal(); GUILayout.Space(10f); if (GUILayout.Button(EditorGUIUtility.TextContent("All"), new GUILayoutOption[1] { GUILayout.Width(50f) })) { this.m_Tree.SetAllEnabled(PackageImportTreeView.EnabledState.All); } if (GUILayout.Button(EditorGUIUtility.TextContent("None"), new GUILayoutOption[1] { GUILayout.Width(50f) })) { this.m_Tree.SetAllEnabled(PackageImportTreeView.EnabledState.None); } this.ReInstallToggle(); GUILayout.FlexibleSpace(); if (GUILayout.Button(EditorGUIUtility.TextContent("Cancel"))) { PopupWindowWithoutFocus.Hide(); this.Close(); GUIUtility.ExitGUI(); } if (GUILayout.Button(EditorGUIUtility.TextContent("Import"))) { bool flag = true; if (this.doReInstall) { flag = EditorUtility.DisplayDialog("Re-Install?", "Highlighted folders will be completely deleted first! Recommend backing up your project first. Are you sure?", "Do It", "Cancel"); } if (flag) { if (this.m_ImportPackageItems != null) { PackageUtility.ImportPackageAssets(this.m_ImportPackageItems, this.doReInstall); } PopupWindowWithoutFocus.Hide(); this.Close(); GUIUtility.ExitGUI(); } } GUILayout.Space(10f); GUILayout.EndHorizontal(); GUILayout.Space(5f); GUILayout.EndVertical(); }
public void CullNonExistingItemsFromSelection() { for (int i = state.selectedIDs.Count - 1; i >= 0; i--) { if (TreeViewUtility.FindItem(state.selectedIDs[i], rootItem) == null) { state.selectedIDs.RemoveAt(i); } } if (state.selectedIDs.Count != 1 && PopupWindowWithoutFocus.IsVisible()) { PopupWindowWithoutFocus.Hide(); } }
protected override void SelectionChanged(IList <int> selectedIds) { base.SelectionChanged(selectedIds); if (selectedIds.Count == 1) { // Not guaranteed to be a PrefabOverridesTreeViewItem. // If there are no overrides, the one item in the tree is not. var selectedItem = FindItem(selectedIds[0], rootItem) as PrefabOverridesTreeViewItem; if (selectedItem != null && selectedItem.obj != null) { m_ShowPreviewForID = selectedIds[0]; return; } } PopupWindowWithoutFocus.Hide(); }
public void OnGUI(Rect rect) { if (Event.current.type == EventType.ScrollWheel) { PopupWindowWithoutFocus.Hide(); } int controlID = GUIUtility.GetControlID(FocusType.Keyboard); this.m_TreeView.OnGUI(rect, controlID); if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Space && this.m_Selection != null && this.m_Selection.Count > 0 && GUIUtility.keyboardControl == controlID) { int enabled = (this.m_Selection[0].item.enabled != 0) ? 0 : 1; this.m_Selection[0].item.enabled = enabled; this.ItemWasToggled(this.m_Selection[0]); Event.current.Use(); } }
void DoPreviewPopup(PrefabOverridesTreeViewItem item, Rect rowRect) { if (item != null) { // Ensure preview is shown when clicking on an already selected item (the preview might have been closed) if (Event.current.type == EventType.MouseDown && rowRect.Contains(Event.current.mousePosition) && !PopupWindowWithoutFocus.IsVisible()) { m_ShowPreviewForID = item.id; } // Show preview if (item.id == m_ShowPreviewForID && Event.current.type != EventType.Layout) { m_ShowPreviewForID = -1; if (item.obj != null) { Rect buttonRect = rowRect; buttonRect.width = EditorGUIUtility.currentViewWidth; Object rowObject = item.obj; Object instance, source; if (item.type == ItemType.REMOVED_OBJECT) { instance = null; source = rowObject; } else if (item.type == ItemType.ADDED_OBJECT) { instance = rowObject; source = null; } else { instance = rowObject; source = PrefabUtility.GetCorrespondingObjectFromSource(rowObject); } PopupWindowWithoutFocus.Show( buttonRect, new ComparisonViewPopup(source, instance, item.singleModification, this), new[] { PopupLocation.Right, PopupLocation.Left, PopupLocation.Below }); } } } }
void BottomArea() { // Background GUILayout.BeginVertical(ms_Constants.bottomBarBg); GUILayout.Space(8); GUILayout.BeginHorizontal(); GUILayout.Space(10); if (GUILayout.Button(EditorGUIUtility.TrTextContent("All"), GUILayout.Width(50))) { m_Tree.SetAllEnabled(PackageImportTreeView.EnabledState.All); } if (GUILayout.Button(EditorGUIUtility.TrTextContent("None"), GUILayout.Width(50))) { m_Tree.SetAllEnabled(PackageImportTreeView.EnabledState.None); } GUILayout.FlexibleSpace(); if (GUILayout.Button(EditorGUIUtility.TrTextContent("Cancel"))) { PackageUtility.ImportPackageAssetsCancelledFromGUI(m_PackageName, m_ImportPackageItems); PopupWindowWithoutFocus.Hide(); Close(); GUIUtility.ExitGUI(); } if (GUILayout.Button(EditorGUIUtility.TrTextContent("Import"))) { if (m_ImportPackageItems != null) { PackageUtility.ImportPackageAssets(m_PackageName, m_ImportPackageItems); } PopupWindowWithoutFocus.Hide(); Close(); GUIUtility.ExitGUI(); } GUILayout.Space(10); GUILayout.EndHorizontal(); GUILayout.Space(5); GUILayout.EndVertical(); }
void DoPreviewPopup(PrefabOverridesTreeViewItem item, Rect rowRect) { if (item == null || item.obj == null) { return; } if (PopupWindowWithoutFocus.IsVisible()) { if (item.id == m_LastShownPreviewWindowRowID) { return; } } Rect buttonRect = rowRect; buttonRect.width = EditorGUIUtility.currentViewWidth; Object rowObject = item.obj; Object instance, source; if (item.type == ItemType.REMOVED_OBJECT) { instance = null; source = rowObject; } else if (item.type == ItemType.ADDED_OBJECT) { instance = rowObject; source = null; } else { instance = rowObject; source = PrefabUtility.GetCorrespondingObjectFromSource(rowObject); } m_LastShownPreviewWindowRowID = item.id; PopupWindowWithoutFocus.Show( buttonRect, new ComparisonViewPopup(source, instance, item.singleModification, this), new[] { PopupLocation.Right, PopupLocation.Left, PopupLocation.Below }); }
public void OnGUI(Rect rect) { if (Event.current.type == EventType.ScrollWheel) { PopupWindowWithoutFocus.Hide(); } int controlID = GUIUtility.GetControlID(FocusType.Keyboard); this.m_TreeView.OnGUI(rect, controlID); if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Space && this.m_Selection != null && this.m_Selection.Count > 0 && GUIUtility.keyboardControl == controlID) { PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem = this.m_Selection[0]; if (packageImportTreeViewItem != null) { PackageImportTreeView.EnabledState enableState = (packageImportTreeViewItem.enableState != PackageImportTreeView.EnabledState.None) ? PackageImportTreeView.EnabledState.None : PackageImportTreeView.EnabledState.All; packageImportTreeViewItem.enableState = enableState; this.ItemWasToggled(this.m_Selection[0]); } Event.current.Use(); } }
private void DoPreviewPopup(PackageImportTreeView.PackageImportTreeViewItem pitem, Rect rowRect) { if (((Event.current.type == EventType.MouseDown) && rowRect.Contains(Event.current.mousePosition)) && !PopupWindowWithoutFocus.IsVisible()) { this.showPreviewForID = pitem.id; } if ((pitem.id == this.showPreviewForID) && (Event.current.type != EventType.Layout)) { this.showPreviewForID = 0; if (!string.IsNullOrEmpty(pitem.item.previewPath)) { Texture2D preview = PackageImport.GetPreview(pitem.item.previewPath); Rect activatorRect = rowRect; activatorRect.width = EditorGUIUtility.currentViewWidth; PopupLocationHelper.PopupLocation[] locationPriorityOrder = new PopupLocationHelper.PopupLocation[3]; locationPriorityOrder[0] = PopupLocationHelper.PopupLocation.Right; locationPriorityOrder[1] = PopupLocationHelper.PopupLocation.Left; PopupWindowWithoutFocus.Show(activatorRect, new PackageImportTreeView.PreviewPopup(preview), locationPriorityOrder); } } }
/// Make a field for a generic mask. /// This version also gives you back which flags were changed and what they were changed to. /// This is useful if you want to make the same change to multiple objects. internal static int DoMaskField(Rect position, int controlID, int mask, string[] flagNames, int[] flagValues, GUIStyle style, out int changedFlags, out bool changedToValue, Type enumType = null) { mask = MaskCallbackInfo.GetSelectedValueForControl(controlID, mask, out changedFlags, out changedToValue); GetMenuOptions(mask, flagNames, flagValues, out var buttonText, out var buttonTextMixed, out var optionNames, out var optionMaskValues, out var selectedOptions, enumType); Event evt = Event.current; if (evt.type == EventType.Repaint) { var buttonContent = EditorGUI.showMixedValue ? EditorGUI.mixedValueContent : DoMixedLabel(buttonText, buttonTextMixed, position, style); style.Draw(position, buttonContent, controlID, false, position.Contains(evt.mousePosition)); } else if ((evt.type == EventType.MouseDown && position.Contains(evt.mousePosition)) || evt.MainActionKeyForControl(controlID)) { MaskCallbackInfo.m_Instance = new MaskCallbackInfo(controlID); PopupWindowWithoutFocus.Show(position, new MaskFieldDropDown(optionNames, optionMaskValues, mask, MaskCallbackInfo.m_Instance.SetMaskValueDelegate)); } return(mask); }
public void OnGUI(Rect rect) { if (Event.current.type == EventType.ScrollWheel) { PopupWindowWithoutFocus.Hide(); } int controlID = GUIUtility.GetControlID(FocusType.Keyboard); this.m_TreeView.OnGUI(rect, controlID); if ((((Event.current.type == EventType.KeyDown) && (Event.current.keyCode == KeyCode.Space)) && ((this.m_Selection != null) && (this.m_Selection.Count > 0))) && (GUIUtility.keyboardControl == controlID)) { ImportPackageItem item = this.m_Selection[0].item; if (item != null) { int num2 = (item.enabledStatus != 0) ? 0 : 1; item.enabledStatus = num2; this.ItemWasToggled(this.m_Selection[0]); } Event.current.Use(); } }
private void ShowKeywords(Shader s) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Keywords", EditorStyles.miniButton); Rect buttonRect = GUILayoutUtility.GetRect(Styles.arrayValuePopupButton, GUI.skin.button, GUILayout.MinWidth(kValueFieldWidth)); buttonRect.width = kArrayValuePopupBtnWidth; if (GUI.Button(buttonRect, Styles.arrayValuePopupButton, EditorStyles.miniButton)) { var globalKeywords = ShaderUtil.GetShaderGlobalKeywords(s); var localKeywords = ShaderUtil.GetShaderLocalKeywords(s); PopupWindowWithoutFocus.Show( buttonRect, new KeywordsPopup(globalKeywords, localKeywords, 150.0f), new[] { PopupLocation.Left, PopupLocation.Below, PopupLocation.Right }); } EditorGUILayout.EndHorizontal(); }
public void OnGUI(Rect rect) { if (Event.current.type == EventType.ScrollWheel) { PopupWindowWithoutFocus.Hide(); } int controlID = GUIUtility.GetControlID(FocusType.Keyboard); this.m_TreeView.OnGUI(rect, controlID); if ((((Event.current.type == EventType.KeyDown) && (Event.current.keyCode == KeyCode.Space)) && ((this.m_Selection != null) && (this.m_Selection.Count > 0))) && (GUIUtility.keyboardControl == controlID)) { PackageImportTreeViewItem item = this.m_Selection[0]; if (item != null) { EnabledState state = (item.enableState != EnabledState.None) ? EnabledState.None : EnabledState.All; item.enableState = state; this.ItemWasToggled(this.m_Selection[0]); } Event.current.Use(); } }
void DrawUnusedOverridesButton() { Rect buttonRect = GUILayoutUtility.GetRect(100, 10000, k_NoOverridesLabelHeight, k_NoOverridesLabelHeight); if (Event.current.type == EventType.Repaint) { if (UnusedOverridesViewPopup.s_IsOpen) { Styles.removeOverridesButtonSelectionStyle.Draw(buttonRect, false, false, true, true); } Rect buttonBorder = new Rect(buttonRect.x, buttonRect.y, buttonRect.width, 1); EditorGUI.DrawRect(buttonBorder, horizontalLineColor);// Upper border. buttonBorder.y = buttonRect.y + buttonRect.height; EditorGUI.DrawRect(buttonBorder, horizontalLineColor);// Lower border. Styles.removeOverridesButtonLineStyle.Draw(buttonRect, Styles.removeUnusedOverridesButtonContent, false, false, UnusedOverridesViewPopup.s_IsOpen, true); } var isHovered = buttonRect.Contains(UnityEngine.Event.current.mousePosition); if (isHovered) { GUIView.current.MarkHotRegion(GUIClip.UnclipToWindow(buttonRect)); using (new GUI.BackgroundColorScope(GameObjectStyles.hoveredBackgroundColor)) { GUI.Label(buttonRect, GUIContent.none, GameObjectStyles.hoveredItemBackgroundStyle); } } if (GUI.Button(buttonRect, GUIContent.none, GUIStyle.none)) { PopupWindowWithoutFocus.Show(buttonRect, new UnusedOverridesViewPopup(m_SelectedGameObjects, this), new[] { PopupLocation.Left, PopupLocation.Right }); } }
public void OnGUI(Rect rect) { if (Event.current.type == EventType.ScrollWheel) { PopupWindowWithoutFocus.Hide(); } int controlId = GUIUtility.GetControlID(FocusType.Keyboard); this.m_TreeView.OnGUI(rect, controlId); if (Event.current.type != EventType.KeyDown || Event.current.keyCode != KeyCode.Space || (this.m_Selection == null || this.m_Selection.Count <= 0) || GUIUtility.keyboardControl != controlId) { return; } PackageImportTreeView.PackageImportTreeViewItem importTreeViewItem = this.m_Selection[0]; if (importTreeViewItem != null) { PackageImportTreeView.EnabledState enabledState = importTreeViewItem.enableState != PackageImportTreeView.EnabledState.None ? PackageImportTreeView.EnabledState.None : PackageImportTreeView.EnabledState.All; importTreeViewItem.enableState = enabledState; this.ItemWasToggled(this.m_Selection[0]); } Event.current.Use(); }
private void SelectionChanged(int[] selectedIDs) { this.m_Selection = new List <PackageImportTreeViewItem>(); foreach (TreeViewItem item in this.m_TreeView.data.GetVisibleRows()) { if (selectedIDs.Contains <int>(item.id)) { PackageImportTreeViewItem item2 = item as PackageImportTreeViewItem; if (item2 != null) { this.m_Selection.Add(item2); } } } if ((this.m_Selection.Count == 1) && !string.IsNullOrEmpty(this.m_Selection[0].item.previewPath)) { PackageImportTreeViewGUI gui = this.m_TreeView.gui as PackageImportTreeViewGUI; gui.showPreviewForID = this.m_Selection[0].id; } else { PopupWindowWithoutFocus.Hide(); } }
private void DoPreviewPopup(PackageImportTreeView.PackageImportTreeViewItem pitem, Rect rowRect) { ImportPackageItem item = pitem.item; if (item != null) { if (Event.current.type == EventType.MouseDown && rowRect.Contains(Event.current.mousePosition) && !PopupWindowWithoutFocus.IsVisible()) { this.showPreviewForID = pitem.id; } if (pitem.id == this.showPreviewForID && Event.current.type != EventType.Layout) { this.showPreviewForID = 0; if (!string.IsNullOrEmpty(item.previewPath)) { Texture2D preview = PackageImport.GetPreview(item.previewPath); Rect rect = rowRect; rect.width = EditorGUIUtility.currentViewWidth; Rect arg_AF_0 = rect; PopupWindowContent arg_AF_1 = new PackageImportTreeView.PreviewPopup(preview); PopupLocationHelper.PopupLocation[] expr_A7 = new PopupLocationHelper.PopupLocation[3]; expr_A7[0] = PopupLocationHelper.PopupLocation.Right; expr_A7[1] = PopupLocationHelper.PopupLocation.Left; PopupWindowWithoutFocus.Show(arg_AF_0, arg_AF_1, expr_A7); } } } }
protected override void OnEnable() { base.OnEnable(); hideFlags = HideFlags.DontSave; s_PopupWindowWithoutFocus = this; }
private void OnEnable() { PopupWindowWithoutFocus.s_PopupWindowWithoutFocus = this; }
public override Rect OnRowGUI(TreeViewItem node, int row, float rowWidth, bool selected, bool focused) { Rect rect = new Rect(0f, (float)row * this.k_LineHeight, rowWidth, this.k_LineHeight); this.DoNodeGUI(rect, node, selected, focused, false); PackageImportTreeView.PackageImportTreeViewItem packageImportTreeViewItem = node as PackageImportTreeView.PackageImportTreeViewItem; if (packageImportTreeViewItem != null) { Rect toggleRect = new Rect(2f, rect.y, rect.height, rect.height); EditorGUI.BeginChangeCheck(); PackageImportTreeView.PackageImportTreeViewGUI.Toggle(packageImportTreeViewItem, toggleRect); if (EditorGUI.EndChangeCheck()) { if (this.m_TreeView.GetSelection().Length <= 1 || !this.m_TreeView.GetSelection().Contains(packageImportTreeViewItem.id)) { this.m_TreeView.SetSelection(new int[] { packageImportTreeViewItem.id }, false); this.m_TreeView.NotifyListenersThatSelectionChanged(); } if (this.itemWasToggled != null) { this.itemWasToggled(packageImportTreeViewItem); } Event.current.Use(); } if (Event.current.type == EventType.MouseDown && rect.Contains(Event.current.mousePosition) && !PopupWindowWithoutFocus.IsVisible()) { this.showPreviewForID = packageImportTreeViewItem.id; } if (packageImportTreeViewItem.id == this.showPreviewForID && Event.current.type != EventType.Layout) { this.showPreviewForID = 0; if (!string.IsNullOrEmpty(packageImportTreeViewItem.item.previewPath)) { Texture2D preview = PackageImport.GetPreview(packageImportTreeViewItem.item.previewPath); Rect rect2 = rect; rect2.width = EditorGUIUtility.currentViewWidth; Rect arg_190_0 = rect2; PopupWindowContent arg_190_1 = new PackageImportTreeView.PreviewPopup(preview); PopupLocationHelper.PopupLocation[] expr_188 = new PopupLocationHelper.PopupLocation[3]; expr_188[0] = PopupLocationHelper.PopupLocation.Right; expr_188[1] = PopupLocationHelper.PopupLocation.Left; PopupWindowWithoutFocus.Show(arg_190_0, arg_190_1, expr_188); } } if (packageImportTreeViewItem.item.exists == 0) { Texture image = this.constants.badgeNew.image; GUI.DrawTexture(new Rect(rect.xMax - (float)image.width - 6f, rect.y + (rect.height - (float)image.height) / 2f, (float)image.width, (float)image.height), image); } } return(rect); }
void DoPreviewPopup(PackageImportTreeViewItem pitem, Rect rowRect) { var item = pitem.item; if (item != null) { // Ensure preview is shown when clicking on an already selected item (the preview might have been closed) if (Event.current.type == EventType.MouseDown && rowRect.Contains(Event.current.mousePosition) && !PopupWindowWithoutFocus.IsVisible()) { showPreviewForID = pitem.id; } // Show preview if (pitem.id == showPreviewForID && Event.current.type != EventType.Layout) { showPreviewForID = 0; if (!string.IsNullOrEmpty(item.previewPath)) { Texture2D preview = PackageImport.GetPreview(item.previewPath); Rect buttonRect = rowRect; buttonRect.width = EditorGUIUtility.currentViewWidth; PopupWindowWithoutFocus.Show(buttonRect, new PreviewPopup(preview), new[] { PopupLocationHelper.PopupLocation.Right, PopupLocationHelper.PopupLocation.Left, PopupLocationHelper.PopupLocation.Below }); } } } }
public static void Show(Rect activatorRect, PopupWindowContent windowContent) { PopupWindowWithoutFocus.Show(activatorRect, windowContent, (PopupLocationHelper.PopupLocation[])null); }
public static void Show(Rect activatorRect, PopupWindowContent windowContent) { PopupWindowWithoutFocus.Show(activatorRect, windowContent, null); }
private void OnEnable() { base.hideFlags = HideFlags.DontSave; PopupWindowWithoutFocus.s_PopupWindowWithoutFocus = this; }
private void OnEnable() { base.hideFlags = HideFlags.DontSave; s_PopupWindowWithoutFocus = this; }
private void DoPreviewPopup(PackageImportTreeView.PackageImportTreeViewItem pitem, Rect rowRect) { ImportPackageItem importPackageItem = pitem.item; if (importPackageItem == null) { return; } if (Event.current.type == EventType.MouseDown && rowRect.Contains(Event.current.mousePosition) && !PopupWindowWithoutFocus.IsVisible()) { this.showPreviewForID = pitem.id; } if (pitem.id != this.showPreviewForID || Event.current.type == EventType.Layout) { return; } this.showPreviewForID = 0; if (string.IsNullOrEmpty(importPackageItem.previewPath)) { return; } Texture2D preview = PackageImport.GetPreview(importPackageItem.previewPath); Rect activatorRect = rowRect; activatorRect.width = EditorGUIUtility.currentViewWidth; PopupWindowWithoutFocus.Show(activatorRect, (PopupWindowContent) new PackageImportTreeView.PreviewPopup(preview), new PopupLocationHelper.PopupLocation[3] { PopupLocationHelper.PopupLocation.Right, PopupLocationHelper.PopupLocation.Left, PopupLocationHelper.PopupLocation.Below }); }
protected override void OnDisable() { base.OnDisable(); s_PopupWindowWithoutFocus = null; }
void OnEnable() { hideFlags = HideFlags.DontSave; s_PopupWindowWithoutFocus = this; }