public static DisplayCustomMenu ( |
||
position | ||
options | ||
selected | int | |
callback | SelectMenuItemFunction | |
userData | object | |
return | void |
private void ShowScriptPopup(Rect r) { int length = m_DefaultTimeScripts.Count; string[] names = new string[length]; bool[] enabled = new bool[length]; for (int c = 0; c < length; c++) { names[c] = m_DefaultTimeScripts[c].GetClass().FullName; // TODO: localization with a proper database. enabled[c] = true; } EditorUtility.DisplayCustomMenu(r, names, enabled, null, MenuSelection, null); }
public static void DisplayCustomMenu(Rect position, GUIContent[] options, int selected, EditorUtility.SelectMenuItemFunction callback, object userData, bool showHotkey) { int[] selected2 = new int[] { selected }; string[] array = new string[options.Length]; for (int i = 0; i < options.Length; i++) { array[i] = options[i].text; } EditorUtility.DisplayCustomMenu(position, array, selected2, callback, userData, showHotkey); }
private void ShowScriptPopup(Rect r) { int count = this.m_DefaultTimeScripts.Count; string[] options = new string[count]; bool[] enabled = new bool[count]; for (int i = 0; i < count; i++) { options[i] = this.m_DefaultTimeScripts[i].GetClass().FullName; enabled[i] = true; } EditorUtility.DisplayCustomMenu(r, options, enabled, null, new EditorUtility.SelectMenuItemFunction(this.MenuSelection), null); }
private void DrawSettingsGUI() { Vector2 vector = EditorStyles.iconButton.CalcSize(EditorGUI.GUIContents.titleSettingsIcon); Rect rect = GUILayoutUtility.GetRect(vector.x, vector.y); if (EditorGUI.DropdownButton(rect, EditorGUI.GUIContents.titleSettingsIcon, FocusType.Passive, EditorStyles.iconButton)) { EditorUtility.DisplayCustomMenu(rect, new GUIContent[] { EditorGUIUtility.TrTextContent("Reset", null, null) }, -1, new EditorUtility.SelectMenuItemFunction(this.ResetSettings), null); } }
private void ShowScriptPopup(Rect r) { int count = this.m_DefaultTimeScripts.Count; string[] array = new string[count]; bool[] array2 = new bool[count]; for (int i = 0; i < count; i++) { array[i] = this.m_DefaultTimeScripts[i].GetClass().FullName; array2[i] = true; } EditorUtility.DisplayCustomMenu(r, array, array2, null, new EditorUtility.SelectMenuItemFunction(this.MenuSelection), null); }
public void OnAssetStatusGUI(Rect r, int id, Object target, GUIStyle style) { if (target == (Object)null) { return; } string modificationString = this.GetModificationString(this.GetChangeFlags()); GUIContent content = !(modificationString == string.Empty) ? new GUIContent("Locally " + modificationString) : EditorGUIUtility.TextContent("Asset is unchanged"); if (!EditorGUI.DoToggle(r, id, false, content, style)) { return; } GUIUtility.hotControl = 0; r = new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 1f, 1f); EditorUtility.DisplayCustomMenu(r, !(modificationString == string.Empty) ? this.m_Menu : this.m_UnmodifiedMenu, -1, new EditorUtility.SelectMenuItemFunction(this.ContextMenuClick), (object)(modificationString == string.Empty)); }
private void DoWindowPopup() { string t = "<Please Select>"; if ((UnityEngine.Object) this.m_Inspected != (UnityEngine.Object)null) { t = GUIViewDebuggerWindow.GetViewName(this.m_Inspected); } GUILayout.Label("Inspected Window: ", new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }); Rect rect = GUILayoutUtility.GetRect(GUIContent.Temp(t), EditorStyles.toolbarDropDown, new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if (!GUI.Button(rect, GUIContent.Temp(t), EditorStyles.toolbarDropDown)) { return; } List <GUIView> views = new List <GUIView>(); GUIViewDebuggerHelper.GetViews(views); List <GUIContent> guiContentList = new List <GUIContent>(views.Count + 1); guiContentList.Add(new GUIContent("None")); int selected = 0; List <GUIView> guiViewList = new List <GUIView>(views.Count + 1); for (int index = 0; index < views.Count; ++index) { GUIView view = views[index]; if (this.CanInspectView(view)) { GUIContent guiContent = new GUIContent(guiContentList.Count.ToString() + ". " + GUIViewDebuggerWindow.GetViewName(view)); guiContentList.Add(guiContent); guiViewList.Add(view); if ((UnityEngine.Object)view == (UnityEngine.Object) this.m_Inspected) { selected = guiViewList.Count; } } } EditorUtility.DisplayCustomMenu(rect, guiContentList.ToArray(), selected, new EditorUtility.SelectMenuItemFunction(this.OnWindowSelected), (object)guiViewList); }
public void OnGUI(Rect connectRect, GUIContent profilerLabel) { if (EditorGUI.ButtonMouseDown(connectRect, profilerLabel, FocusType.Passive, EditorStyles.toolbarDropDown)) { List <ProfilerChoise> list = new List <ProfilerChoise>(); list.Clear(); AttachProfilerUI.AddPlayerProfilers(list); AttachProfilerUI.AddDeviceProfilers(list); AttachProfilerUI.AddLastIPProfiler(list); if (!ProfilerDriver.IsConnectionEditor()) { if (!list.Any((ProfilerChoise p) => p.IsSelected())) { List <ProfilerChoise> arg_D2_0 = list; ProfilerChoise item = default(ProfilerChoise); item.Name = "(Autoconnected Player)"; item.Enabled = false; item.IsSelected = (() => true); item.ConnectTo = delegate { }; arg_D2_0.Add(item); } } this.AddEnterIPProfiler(list, GUIUtility.GUIToScreenRect(connectRect)); string[] options = (from p in list select p.Name).ToArray <string>(); bool[] enabled = (from p in list select p.Enabled).ToArray <bool>(); int num = list.FindIndex((ProfilerChoise p) => p.IsSelected()); int[] selected; if (num == -1) { selected = new int[0]; } else { selected = new int[] { num }; } EditorUtility.DisplayCustomMenu(connectRect, options, enabled, selected, new EditorUtility.SelectMenuItemFunction(this.SelectProfilerClick), list); } }
private void DisplayAddVariantsMenu(Rect rect, Shader shader, ShaderVariantCollection collection) { ShaderVariantCollectionInspector.AddVariantMenuData addVariantMenuData = new ShaderVariantCollectionInspector.AddVariantMenuData(); addVariantMenuData.shader = shader; addVariantMenuData.collection = collection; ShaderUtil.GetShaderVariantEntries(shader, collection, out addVariantMenuData.types, out addVariantMenuData.keywords); if (addVariantMenuData.keywords.Length == 0) { EditorApplication.Beep(); return; } string[] array = new string[addVariantMenuData.keywords.Length]; for (int i = 0; i < addVariantMenuData.keywords.Length; i++) { array[i] = (PassType)addVariantMenuData.types[i] + "/" + ((!string.IsNullOrEmpty(addVariantMenuData.keywords[i])) ? addVariantMenuData.keywords[i] : "<no keywords>"); } EditorUtility.DisplayCustomMenu(rect, array, null, new EditorUtility.SelectMenuItemFunction(this.AddVariantMenuSelected), addVariantMenuData); }
private void DoWindowPopup() { string t = "<Please Select>"; if (this.m_Inspected != null) { t = GUIViewDebuggerWindow.GetViewName(this.m_Inspected); } GUILayout.Label("Inspected Window: ", new GUILayoutOption[] { GUILayout.ExpandWidth(false) }); Rect rect = GUILayoutUtility.GetRect(GUIContent.Temp(t), EditorStyles.toolbarDropDown, new GUILayoutOption[] { GUILayout.ExpandWidth(true) }); if (GUI.Button(rect, GUIContent.Temp(t), EditorStyles.toolbarDropDown)) { List <GUIView> list = new List <GUIView>(); GUIViewDebuggerHelper.GetViews(list); List <GUIContent> list2 = new List <GUIContent>(list.Count + 1); list2.Add(new GUIContent("None")); int selected = 0; List <GUIView> list3 = new List <GUIView>(list.Count + 1); for (int i = 0; i < list.Count; i++) { GUIView gUIView = list[i]; if (this.CanInspectView(gUIView)) { string text = list2.Count + ". " + GUIViewDebuggerWindow.GetViewName(gUIView); GUIContent item = new GUIContent(text); list2.Add(item); list3.Add(gUIView); if (gUIView == this.m_Inspected) { selected = list3.Count; } } } EditorUtility.DisplayCustomMenu(rect, list2.ToArray(), selected, new EditorUtility.SelectMenuItemFunction(this.OnWindowSelected), list3); } }
void DoWindowPopup() { string selectedName = inspected == null ? Styles.defaultWindowPopupText : GetViewName(inspected); GUILayout.Label(Styles.inspectedWindowLabel, GUILayout.ExpandWidth(false)); Rect popupPosition = GUILayoutUtility.GetRect(GUIContent.Temp(selectedName), EditorStyles.toolbarDropDown, GUILayout.ExpandWidth(true)); if (GUI.Button(popupPosition, GUIContent.Temp(selectedName), EditorStyles.toolbarDropDown)) { List <GUIView> views = new List <GUIView>(); GUIViewDebuggerHelper.GetViews(views); List <GUIContent> options = new List <GUIContent>(views.Count + 1); options.Add(EditorGUIUtility.TrTextContent("None")); int selectedIndex = 0; List <GUIView> selectableViews = new List <GUIView>(views.Count + 1); for (int i = 0; i < views.Count; ++i) { GUIView view = views[i]; //We can't inspect ourselves, otherwise we get infinite recursion. //Also avoid the InstructionOverlay if (!CanInspectView(view)) { continue; } GUIContent label = new GUIContent(string.Format("{0}. {1}", options.Count, GetViewName(view))); options.Add(label); selectableViews.Add(view); if (view == inspected) { selectedIndex = selectableViews.Count; } } //TODO: convert this to a Unity Window style popup. This way we could highlight the window on hover ;) EditorUtility.DisplayCustomMenu(popupPosition, options.ToArray(), selectedIndex, OnWindowSelected, selectableViews); } }
private void ShowScriptPopup(Rect r) { int length = m_DefaultTimeScripts.Count; string[] names = new string[length]; bool[] enabled = new bool[length]; var lockedScripts = new HashSet <MonoScript>(); if (Provider.enabled) { var assetList = new AssetList(); var pathToScript = new Dictionary <string, MonoScript>(); for (int i = 0; i < length; i++) { var metaPath = AssetDatabase.GetTextMetaFilePathFromAssetPath(AssetDatabase.GetAssetPath(m_DefaultTimeScripts[i])); if (Provider.GetAssetByPath(metaPath) != null) { assetList.Add(Provider.GetAssetByPath(metaPath)); pathToScript.Add(metaPath, m_DefaultTimeScripts[i]); } } Provider.Status(assetList).Wait(); const Asset.States kExclusiveLockedRemote = Asset.States.Exclusive | Asset.States.LockedRemote; foreach (var asset in assetList) { if ((asset.state & kExclusiveLockedRemote) == kExclusiveLockedRemote) { lockedScripts.Add(pathToScript[asset.metaPath]); } } } for (int c = 0; c < length; c++) { names[c] = m_DefaultTimeScripts[c].GetClass().FullName; // TODO: localization with a proper database. enabled[c] = !lockedScripts.Contains(m_DefaultTimeScripts[c]); //List item is disabled when asset is locked } EditorUtility.DisplayCustomMenu(r, names, enabled, null, MenuSelection, null); }
protected virtual void OnGUIMenu(Rect connectRect, List <ProfilerChoise> profilers) { string[] names = profilers.Select(p => p.Name).ToArray(); bool[] enabled = profilers.Select(p => p.Enabled).ToArray(); int[] selected; int index = profilers.FindIndex(p => p.IsSelected()); if (index == -1) { selected = new int[0]; } else { selected = new int[] { index } }; EditorUtility.DisplayCustomMenu(connectRect, names, enabled, selected, SelectProfilerClick, profilers); } }
void DrawSettingsGUI(Mode mode) { if (mode == Mode.LightingSettings || mode == Mode.EnvironmentSettings) { var iconSize = EditorStyles.iconButton.CalcSize(EditorGUI.GUIContents.titleSettingsIcon); var rect = GUILayoutUtility.GetRect(iconSize.x, iconSize.y); if (EditorGUI.DropdownButton(rect, EditorGUI.GUIContents.titleSettingsIcon, FocusType.Passive, EditorStyles.iconButton)) { if (mode == Mode.LightingSettings) { EditorUtility.DisplayCustomMenu(rect, new[] { EditorGUIUtility.TrTextContent("Reset") }, -1, ResetLightingSettings, null); } else if (mode == Mode.EnvironmentSettings) { EditorUtility.DisplayCustomMenu(rect, new[] { EditorGUIUtility.TrTextContent("Reset") }, -1, ResetEnvironmentSettings, null); } } } }
void AllocationCallstacksToolbarItem() { if (Unsupported.IsDeveloperMode()) { bool toggled = m_SelectedMemRecordMode != ProfilerMemoryRecordMode.None; var oldToggleState = toggled; if (EditorGUILayout.DropDownToggle(ref toggled, Styles.recordCallstacks, EditorStyles.toolbarDropDownToggle)) { Rect rect = GUILayoutUtility.topLevel.GetLast(); string[] names = new string[] { L10n.Tr("None"), L10n.Tr("Managed Allocations") }; if (Unsupported.IsDeveloperMode()) { names = new string[] { L10n.Tr("None"), L10n.Tr("Managed Allocations"), L10n.Tr("All Allocations (fast)"), L10n.Tr("All Allocations (full)") }; } var enabled = new bool[names.Length]; for (int c = 0; c < names.Length; ++c) { enabled[c] = true; } var selected = new int[] { (int)m_SelectedMemRecordMode }; EditorUtility.DisplayCustomMenu(rect, names, enabled, selected, MemRecordModeClick, null); GUIUtility.ExitGUI(); } if (toggled != oldToggleState) { m_SelectedMemRecordMode = (m_SelectedMemRecordMode != ProfilerMemoryRecordMode.None) ? ProfilerMemoryRecordMode.None : (m_LastSelectedMemRecordMode == ProfilerMemoryRecordMode.None ? ProfilerMemoryRecordMode.ManagedAllocations : m_LastSelectedMemRecordMode); } } else { m_SelectedMemRecordMode = GUILayout.Toggle(m_SelectedMemRecordMode == ProfilerMemoryRecordMode.ManagedAllocations, Styles.recordCallstacks, EditorStyles.toolbarButton) ? ProfilerMemoryRecordMode.ManagedAllocations : ProfilerMemoryRecordMode.None; } }
private void FilePopup(string label, string selectedString, ref string[] names, ref string[] paths, PreferencesWindow.RefString outString, Action onChanged) { GUIStyle popup = EditorStyles.popup; GUILayout.BeginHorizontal(new GUILayoutOption[0]); EditorGUILayout.PrefixLabel(label, popup); int[] array = new int[] { Array.IndexOf <string>(paths, selectedString) }; GUIContent content = new GUIContent(names[array[0]]); Rect rect = GUILayoutUtility.GetRect(GUIContent.none, popup); PreferencesWindow.AppsListUserData userData = new PreferencesWindow.AppsListUserData(paths, outString, onChanged); if (EditorGUI.ButtonMouseDown(rect, content, FocusType.Native, popup)) { ArrayUtility.Add <string>(ref names, "Browse..."); EditorUtility.DisplayCustomMenu(rect, names, array, new EditorUtility.SelectMenuItemFunction(this.AppsListClick), userData); } GUILayout.EndHorizontal(); }
private void DoWindowPopup() { string t = "<Please Select>"; if (this.m_Inspected != null) { t = GetViewName(this.m_Inspected); } GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.ExpandWidth(false) }; GUILayout.Label("Inspected Window: ", options); GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.ExpandWidth(true) }; Rect position = GUILayoutUtility.GetRect(GUIContent.Temp(t), EditorStyles.toolbarDropDown, optionArray2); if (GUI.Button(position, GUIContent.Temp(t), EditorStyles.toolbarDropDown)) { List <GUIView> views = new List <GUIView>(); GUIViewDebuggerHelper.GetViews(views); List <GUIContent> list2 = new List <GUIContent>(views.Count + 1) { new GUIContent("None") }; int selected = 0; List <GUIView> userData = new List <GUIView>(views.Count + 1); for (int i = 0; i < views.Count; i++) { GUIView view = views[i]; if (this.CanInspectView(view)) { GUIContent item = new GUIContent(list2.Count + ". " + GetViewName(view)); list2.Add(item); userData.Add(view); if (view == this.m_Inspected) { selected = userData.Count; } } } EditorUtility.DisplayCustomMenu(position, list2.ToArray(), selected, new EditorUtility.SelectMenuItemFunction(this.OnWindowSelected), userData); } }
private void DisplayAddVariantsMenu(Rect rect, Shader shader, ShaderVariantCollection collection) { AddVariantMenuData userData = new AddVariantMenuData { shader = shader, collection = collection }; ShaderUtil.GetShaderVariantEntries(shader, collection, out userData.types, out userData.keywords); if (userData.keywords.Length == 0) { EditorApplication.Beep(); } else { string[] options = new string[userData.keywords.Length]; for (int i = 0; i < userData.keywords.Length; i++) { options[i] = ((PassType)userData.types[i]) + "/" + (!string.IsNullOrEmpty(userData.keywords[i]) ? userData.keywords[i] : "<no keywords>"); } EditorUtility.DisplayCustomMenu(rect, options, null, new EditorUtility.SelectMenuItemFunction(this.AddVariantMenuSelected), userData); } }
protected virtual void OnGUIMenu(Rect connectRect, List <ProfilerChoise> profilers) { string[] options = (from p in profilers select p.Name).ToArray <string>(); bool[] enabled = (from p in profilers select p.Enabled).ToArray <bool>(); int num = profilers.FindIndex((ProfilerChoise p) => p.IsSelected()); int[] selected; if (num == -1) { selected = new int[0]; } else { selected = new int[] { num }; } EditorUtility.DisplayCustomMenu(connectRect, options, enabled, selected, new EditorUtility.SelectMenuItemFunction(this.SelectProfilerClick), profilers); }
private void DoWindowPopup() { string t = (!(this.inspected == null)) ? GUIViewDebuggerWindow.GetViewName(this.inspected) : GUIViewDebuggerWindow.Styles.defaultWindowPopupText; GUILayout.Label(GUIViewDebuggerWindow.Styles.inspectedWindowLabel, new GUILayoutOption[] { GUILayout.ExpandWidth(false) }); Rect rect = GUILayoutUtility.GetRect(GUIContent.Temp(t), EditorStyles.toolbarDropDown, new GUILayoutOption[] { GUILayout.ExpandWidth(true) }); if (GUI.Button(rect, GUIContent.Temp(t), EditorStyles.toolbarDropDown)) { List <GUIView> list = new List <GUIView>(); GUIViewDebuggerHelper.GetViews(list); List <GUIContent> list2 = new List <GUIContent>(list.Count + 1); list2.Add(EditorGUIUtility.TrTextContent("None", null, null)); int selected = 0; List <GUIView> list3 = new List <GUIView>(list.Count + 1); for (int i = 0; i < list.Count; i++) { GUIView gUIView = list[i]; if (this.CanInspectView(gUIView)) { GUIContent item = new GUIContent(string.Format("{0}. {1}", list2.Count, GUIViewDebuggerWindow.GetViewName(gUIView))); list2.Add(item); list3.Add(gUIView); if (gUIView == this.inspected) { selected = list3.Count; } } } EditorUtility.DisplayCustomMenu(rect, list2.ToArray(), selected, new EditorUtility.SelectMenuItemFunction(this.OnWindowSelected), list3); } }
public void OnAssetStatusGUI(Rect r, int id, UnityEngine.Object target, GUIStyle style) { if (target != null) { GUIContent content; ChangeFlags changeFlags = this.GetChangeFlags(); string modificationString = this.GetModificationString(changeFlags); if (modificationString == string.Empty) { content = EditorGUIUtility.TextContent("Asset is unchanged"); } else { content = new GUIContent("Locally " + modificationString); } if (EditorGUI.DoToggle(r, id, false, content, style)) { GUIUtility.hotControl = 0; r = new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 1f, 1f); EditorUtility.DisplayCustomMenu(r, (modificationString != string.Empty) ? this.m_Menu : this.m_UnmodifiedMenu, -1, new EditorUtility.SelectMenuItemFunction(this.ContextMenuClick), modificationString == string.Empty); } } }
private void FilePopup(GUIContent label, string selectedString, ref string[] names, ref string[] paths, RefString outString, string defaultString, Action onChanged) { GUIStyle style = EditorStyles.popup; GUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(label, style); int[] selected = new int[0]; if (paths.Contains(selectedString)) { selected = new[] { Array.IndexOf(paths, selectedString) } } ; GUIContent text = new GUIContent(selected.Length == 0 ? defaultString : names[selected[0]]); Rect r = GUILayoutUtility.GetRect(GUIContent.none, style); AppsListUserData ud = new AppsListUserData(paths, outString, onChanged); if (EditorGUI.DropdownButton(r, text, FocusType.Passive, style)) { ArrayUtility.Add(ref names, Styles.browse.text); EditorUtility.DisplayCustomMenu(r, names, selected, AppsListClick, ud, false); } GUILayout.EndHorizontal(); }
public void UpdateGUI() { SplitterGUILayout.BeginHorizontalSplit(this.horSplit, new GUILayoutOption[0]); GUILayout.BeginVertical(this.constants.box, new GUILayoutOption[0]); GUILayout.Label(this.totalUpdates, this.constants.title, new GUILayoutOption[0]); IEnumerator enumerator = ListViewGUILayout.ListView(this.lv, GUIStyle.none, new GUILayoutOption[0]).GetEnumerator(); try { while (enumerator.MoveNext()) { ListViewElement current = (ListViewElement)enumerator.Current; Rect position = current.position; position.x++; position.y++; if (Event.current.type == EventType.Repaint) { if ((current.row % 2) == 0) { this.constants.entryEven.Draw(position, false, false, false, false); } else { this.constants.entryOdd.Draw(position, false, false, false, false); } } GUILayout.BeginVertical((current.row != this.lv.row) ? this.constants.entryNormal : this.constants.entrySelected, new GUILayoutOption[0]); GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.MinWidth(50f) }; GUILayout.Label(this.messageFirstLines[current.row], this.constants.serverUpdateLog, options); GUILayout.BeginHorizontal(new GUILayoutOption[0]); GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.MinWidth(100f) }; GUILayout.Label(this.changesets[current.row].changeset.ToString() + " " + this.changesets[current.row].date, this.constants.serverUpdateInfo, optionArray2); GUILayoutOption[] optionArray3 = new GUILayoutOption[] { GUILayout.Width((float)this.maxNickLength) }; GUILayout.Label(this.changesets[current.row].owner, this.constants.serverUpdateInfo, optionArray3); GUILayout.EndHorizontal(); GUILayout.EndVertical(); } } finally { IDisposable disposable = enumerator as IDisposable; if (disposable != null) { disposable.Dispose(); } } if (this.lv.selectionChanged) { this.SetSelectedRevisionLine(this.lv.row); } GUILayout.EndVertical(); SplitterGUILayout.BeginVerticalSplit(this.vertSplit, new GUILayoutOption[0]); GUILayout.BeginVertical(this.constants.box, new GUILayoutOption[0]); GUILayout.Label("Changeset", this.constants.title, new GUILayoutOption[0]); int num = -1; int file = -1; IEnumerator enumerator2 = ListViewGUILayout.ListView(this.pv.lv, GUIStyle.none, new GUILayoutOption[0]).GetEnumerator(); try { while (enumerator2.MoveNext()) { ChangeFlags changeFlags; ListViewElement element2 = (ListViewElement)enumerator2.Current; if ((num == -1) && !this.pv.IndexToFolderAndFile(element2.row, ref num, ref file)) { return; } ParentViewFolder folder = this.pv.folders[num]; if (ListViewGUILayout.HasMouseDown(element2.position)) { if (Event.current.clickCount == 2) { if (!this.isDirSelected && (this.selectedGUID != string.Empty)) { this.DoShowDiff(false); GUIUtility.ExitGUI(); } } else { this.pv.lv.scrollPos = ListViewShared.ListViewScrollToRow(this.pv.lv.ilvState, element2.row); this.DoSelect(num, file, element2.row); } } else if (ListViewGUILayout.HasMouseDown(element2.position, 1)) { if (this.lv.row != element2.row) { this.DoSelect(num, file, element2.row); } if (!this.isDirSelected && (this.selectedGUID != string.Empty)) { GUIUtility.hotControl = 0; Rect rect2 = new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 1f, 1f); EditorUtility.DisplayCustomMenu(rect2, this.dropDownMenuItems, null, new EditorUtility.SelectMenuItemFunction(this.ContextMenuClick), null); Event.current.Use(); } } if ((element2.row == this.pv.lv.row) && (Event.current.type == EventType.Repaint)) { this.constants.entrySelected.Draw(element2.position, false, false, false, false); } if (file != -1) { Texture2D cachedIcon = AssetDatabase.GetCachedIcon(folder.name + "/" + folder.files[file].name) as Texture2D; if (cachedIcon == null) { cachedIcon = InternalEditorUtility.GetIconForFile(folder.files[file].name); } GUILayout.Label(new GUIContent(folder.files[file].name, cachedIcon), this.constants.element, new GUILayoutOption[0]); changeFlags = folder.files[file].changeFlags; } else { GUILayout.Label(folder.name, this.constants.header, new GUILayoutOption[0]); changeFlags = folder.changeFlags; } GUIContent badgeNew = null; if (this.HasFlag(changeFlags, ChangeFlags.Undeleted) || this.HasFlag(changeFlags, ChangeFlags.Created)) { badgeNew = ASMainWindow.constants.badgeNew; } else if (this.HasFlag(changeFlags, ChangeFlags.Deleted)) { badgeNew = ASMainWindow.constants.badgeDelete; } else if (this.HasFlag(changeFlags, ChangeFlags.Renamed) || this.HasFlag(changeFlags, ChangeFlags.Moved)) { badgeNew = ASMainWindow.constants.badgeMove; } if ((badgeNew != null) && (Event.current.type == EventType.Repaint)) { Rect rect3 = new Rect(((element2.position.x + element2.position.width) - badgeNew.image.width) - 5f, (element2.position.y + (element2.position.height / 2f)) - (badgeNew.image.height / 2), (float)badgeNew.image.width, (float)badgeNew.image.height); EditorGUIUtility.SetIconSize(Vector2.zero); GUIStyle.none.Draw(rect3, badgeNew, false, false, false, false); EditorGUIUtility.SetIconSize(this.iconSize); } this.pv.NextFileFolder(ref num, ref file); } } finally { IDisposable disposable2 = enumerator2 as IDisposable; if (disposable2 != null) { disposable2.Dispose(); } } if (this.pv.lv.selectionChanged && (this.selectedGUID != string.Empty)) { if (this.selectedGUID != AssetServer.GetRootGUID()) { AssetServer.SetSelectionFromGUID(this.selectedGUID); } else { AssetServer.SetSelectionFromGUID(string.Empty); } } if ((GUIUtility.keyboardControl == this.pv.lv.ID) && (((Event.current.type == EventType.KeyDown) && (Event.current.keyCode == KeyCode.Return)) && (!this.isDirSelected && (this.selectedGUID != string.Empty)))) { this.DoShowDiff(false); GUIUtility.ExitGUI(); } GUILayout.EndVertical(); GUILayout.BeginVertical(this.constants.box, new GUILayoutOption[0]); GUILayout.Label("Update Message", this.constants.title, new GUILayoutOption[0]); GUILayout.TextArea((this.lv.row < 0) ? "" : this.changesets[this.lv.row].message, this.constants.wwText, new GUILayoutOption[0]); GUILayout.EndVertical(); SplitterGUILayout.EndVerticalSplit(); SplitterGUILayout.EndHorizontalSplit(); }
public void DoDeletedItemsGUI(ASHistoryWindow parentWin, Rect theRect, GUIStyle s, float offset, float endOffset, bool focused) { Event current = Event.current; Texture2D textured = EditorGUIUtility.FindTexture(EditorResourcesUtility.folderIconName); offset += 3f; Rect position = new Rect(this.m_Indent, offset, theRect.width - this.m_Indent, m_RowHeight); if ((current.type == EventType.MouseDown) && position.Contains(current.mousePosition)) { GUIUtility.keyboardControl = this.m_FileViewControlID; this.SelType = SelectionType.DeletedItemsRoot; this.ScrollToDeletedItem(-1); parentWin.DoLocalSelectionChange(); } position.width -= position.x; position.x = 0f; GUIContent content = new GUIContent("Deleted Assets") { image = textured }; int baseIndent = (int)this.m_BaseIndent; s.padding.left = baseIndent; if (current.type == EventType.Repaint) { s.Draw(position, content, false, false, this.SelType == SelectionType.DeletedItemsRoot, focused); } Rect rect2 = new Rect(this.m_BaseIndent - this.m_FoldoutSize, offset, this.m_FoldoutSize, m_RowHeight); if (!this.m_DeletedItemsInitialized || (this.m_DelPVstate.lv.totalRows != 0)) { this.DeletedItemsToggle = GUI.Toggle(rect2, this.DeletedItemsToggle, GUIContent.none, ms_Styles.foldout); } offset += m_RowHeight; if (this.DeletedItemsToggle) { int row = this.m_DelPVstate.lv.row; int index = 0; int num4 = -1; int file = -1; int num6 = 0; while ((offset <= endOffset) && (num6 < this.m_DelPVstate.lv.totalRows)) { if ((offset + m_RowHeight) >= 0f) { if (num4 == -1) { this.m_DelPVstate.IndexToFolderAndFile(num6, ref num4, ref file); } position = new Rect(0f, offset, (float)Screen.width, m_RowHeight); ParentViewFolder folder = this.m_DelPVstate.folders[num4]; if ((current.type == EventType.MouseDown) && position.Contains(current.mousePosition)) { if (!(((current.button == 1) && (this.SelType == SelectionType.DeletedItems)) && this.m_DelPVstate.selectedItems[index])) { GUIUtility.keyboardControl = this.m_FileViewControlID; this.SelType = SelectionType.DeletedItems; this.m_DelPVstate.lv.row = index; ListViewShared.MultiSelection(null, row, this.m_DelPVstate.lv.row, ref this.m_DelPVstate.initialSelectedItem, ref this.m_DelPVstate.selectedItems); this.ScrollToDeletedItem(index); parentWin.DoLocalSelectionChange(); } if ((current.button == 1) && (this.SelType == SelectionType.DeletedItems)) { GUIUtility.hotControl = 0; Rect rect3 = new Rect(current.mousePosition.x, current.mousePosition.y, 1f, 1f); EditorUtility.DisplayCustomMenu(rect3, this.dropDownMenuItems, -1, new EditorUtility.SelectMenuItemFunction(this.ContextMenuClick), null); } Event.current.Use(); } if (file != -1) { content.text = folder.files[file].name; content.image = InternalEditorUtility.GetIconForFile(folder.files[file].name); baseIndent = (int)(this.m_BaseIndent + (this.m_Indent * 2f)); } else { content.text = folder.name; content.image = textured; baseIndent = (int)(this.m_BaseIndent + this.m_Indent); } s.padding.left = baseIndent; if (Event.current.type == EventType.Repaint) { s.Draw(position, content, false, false, this.m_DelPVstate.selectedItems[index], focused); } this.m_DelPVstate.NextFileFolder(ref num4, ref file); index++; } num6++; offset += m_RowHeight; } } }
internal static void DisplayCustomMenu(Rect position, string[] options, bool[] enabled, int[] selected, EditorUtility.SelectMenuItemFunction callback, object userData) { EditorUtility.DisplayCustomMenu(position, options, enabled, selected, callback, userData, false); }
public static void DisplayCustomMenu(Rect position, GUIContent[] options, int selected, EditorUtility.SelectMenuItemFunction callback, object userData) { EditorUtility.DisplayCustomMenu(position, options, selected, callback, userData, false); }
private void AddTransformPathInList(Rect rect, ReorderableList list) { EditorUtility.DisplayCustomMenu(rect, this.m_TransformPaths, null, new EditorUtility.SelectMenuItemFunction(this.TransformPathSelected), null); }
private void WebLikeHistory(bool hasFocus) { if (this.m_Changesets == null) { this.m_Changesets = new Changeset[0]; } if (this.m_GUIItems != null) { this.m_HistoryControlID = GUIUtility.GetControlID(ms_HistoryControlHash, FocusType.Native); this.HandleWebLikeKeyboard(); Event current = Event.current; if (current.GetTypeForControl(this.m_HistoryControlID) == EventType.ValidateCommand) { current.Use(); } else { GUILayout.Space(1f); this.m_ScrollPos = GUILayout.BeginScrollView(this.m_ScrollPos, new GUILayoutOption[0]); int num = 0; GUILayoutUtility.GetRect(1f, (float)(this.m_TotalHeight - 1)); if ((((current.type == EventType.Repaint) || (current.type == EventType.MouseDown)) || (current.type == EventType.MouseUp)) && (this.m_GUIItems != null)) { for (int i = 0; i < this.m_Changesets.Length; i++) { if (this.m_GUIItems[i].inFilter) { if (((num + this.m_GUIItems[i].height) > GUIClip.visibleRect.y) && (num < GUIClip.visibleRect.yMax)) { Rect rect; float num3 = ms_Style.descriptionLabel.CalcHeight(this.m_GUIItems[i].colDescription, float.MaxValue); if (current.type == EventType.Repaint) { if ((this.ChangeLogSelectionRev == this.m_Changesets[i].changeset) && (Event.current.type == EventType.Repaint)) { rect = new Rect(0f, (float)num, GUIClip.visibleRect.width, (float)(this.m_GUIItems[i].height - 10)); ms_Style.selected.Draw(rect, false, false, false, false); } rect = new Rect(0f, (float)(num + 3), GUIClip.visibleRect.width, (float)this.m_GUIItems[i].height); GUI.Label(rect, this.m_GUIItems[i].colAuthor, ms_Style.boldLabel); rect = new Rect(GUIClip.visibleRect.width - 160f, (float)(num + 3), 60f, (float)this.m_GUIItems[i].height); GUI.Label(rect, this.m_GUIItems[i].colRevision, ms_Style.boldLabel); rect.x += 60f; rect.width = 100f; GUI.Label(rect, this.m_GUIItems[i].colDate, ms_Style.boldLabel); rect.x = ms_Style.boldLabel.margin.left; rect.y += this.m_RowHeight; rect.width = GUIClip.visibleRect.width; rect.height = num3; GUI.Label(rect, this.m_GUIItems[i].colDescription, ms_Style.descriptionLabel); rect.y += num3; } rect = new Rect(0f, (num + num3) + this.m_RowHeight, GUIClip.visibleRect.width, (this.m_GUIItems[i].height - num3) - this.m_RowHeight); this.DrawParentView(rect, ref this.m_GUIItems[i], i, hasFocus); if (current.type == EventType.MouseDown) { rect = new Rect(0f, (float)num, GUIClip.visibleRect.width, (float)(this.m_GUIItems[i].height - 10)); if (rect.Contains(current.mousePosition)) { this.ChangeLogSelectionRev = this.m_Changesets[i].changeset; this.m_ChangesetSelectionIndex = i; GUIUtility.keyboardControl = this.m_HistoryControlID; ((ASMainWindow)this.m_ParentWindow).m_SearchToShow = ASMainWindow.ShowSearchField.HistoryList; if (current.button == 1) { GUIUtility.hotControl = 0; rect = new Rect(current.mousePosition.x, current.mousePosition.y, 1f, 1f); EditorUtility.DisplayCustomMenu(rect, this.m_DropDownChangesetMenuItems, -1, new EditorUtility.SelectMenuItemFunction(this.ChangesetContextMenuClick), null); Event.current.Use(); } this.DoScroll(); current.Use(); } } } num += this.m_GUIItems[i].height; } } } else if (this.m_GUIItems == null) { GUILayout.Label(EditorGUIUtility.TextContent("This item is not yet committed to the Asset Server"), new GUILayoutOption[0]); } if (Event.current.type == EventType.Repaint) { this.m_ScrollViewHeight = (int)GUIClip.visibleRect.height; } GUILayout.EndScrollView(); } } }
private void DrawParentView(Rect r, ref GUIHistoryListItem item, int changesetIndex, bool hasFocus) { ParentViewState assets = item.assets; GUIContent content = new GUIContent(); Texture2D textured = EditorGUIUtility.FindTexture(EditorResourcesUtility.folderIconName); Event current = Event.current; hasFocus &= this.m_HistoryControlID == GUIUtility.keyboardControl; r.height = this.m_RowHeight; r.y += 3f; int index = -1; int num2 = (item.collapsedItemCount == 0) ? item.totalLineCount : 4; num2 += item.startShowingFrom; for (int i = 0; i < assets.folders.Length; i++) { GUIStyle label; ParentViewFolder folder = assets.folders[i]; content.text = folder.name; content.image = textured; index++; if (index == num2) { break; } if (index >= item.startShowingFrom) { label = ms_Style.label; if ((current.type == EventType.MouseDown) && r.Contains(current.mousePosition)) { if (((this.ChangeLogSelectionRev == this.m_Changesets[changesetIndex].changeset) && (this.m_ChangeLogSelectionGUID == folder.guid)) && EditorGUI.actionKey) { this.ClearItemSelection(); } else { this.ChangeLogSelectionRev = this.m_Changesets[changesetIndex].changeset; this.m_ChangeLogSelectionGUID = folder.guid; this.m_ChangeLogSelectionAssetName = folder.name; this.m_FolderSelected = true; this.m_AssetSelectionIndex = index; } this.m_ChangesetSelectionIndex = changesetIndex; GUIUtility.keyboardControl = this.m_HistoryControlID; ((ASMainWindow)this.m_ParentWindow).m_SearchToShow = ASMainWindow.ShowSearchField.HistoryList; if (current.clickCount == 2) { this.ShowAssetsHistory(); GUIUtility.ExitGUI(); } else if (current.button == 1) { GUIUtility.hotControl = 0; r = new Rect(current.mousePosition.x, current.mousePosition.y, 1f, 1f); EditorUtility.DisplayCustomMenu(r, this.m_DropDownMenuItems, -1, new EditorUtility.SelectMenuItemFunction(this.ContextMenuClick), null); } this.DoScroll(); current.Use(); } bool on = (this.ChangeLogSelectionRev == this.m_Changesets[changesetIndex].changeset) && (this.m_ChangeLogSelectionGUID == folder.guid); if (item.boldAssets[index] && !on) { GUI.Label(r, string.Empty, ms_Style.ping); } if (Event.current.type == EventType.Repaint) { label.Draw(r, content, false, false, on, hasFocus); this.DrawBadge(r, folder.changeFlags, label, content, GUIClip.visibleRect.width - 150f); } r.y += this.m_RowHeight; } RectOffset padding = ms_Style.label.padding; padding.left += 0x10; RectOffset offset2 = ms_Style.boldLabel.padding; offset2.left += 0x10; try { for (int j = 0; j < folder.files.Length; j++) { index++; if (index == num2) { break; } if (index >= item.startShowingFrom) { label = ms_Style.label; if ((current.type == EventType.MouseDown) && r.Contains(current.mousePosition)) { if (((this.ChangeLogSelectionRev == this.m_Changesets[changesetIndex].changeset) && (this.m_ChangeLogSelectionGUID == folder.files[j].guid)) && EditorGUI.actionKey) { this.ClearItemSelection(); } else { this.ChangeLogSelectionRev = this.m_Changesets[changesetIndex].changeset; this.m_ChangeLogSelectionGUID = folder.files[j].guid; this.m_ChangeLogSelectionAssetName = folder.files[j].name; this.m_FolderSelected = false; this.m_AssetSelectionIndex = index; } this.m_ChangesetSelectionIndex = changesetIndex; GUIUtility.keyboardControl = this.m_HistoryControlID; ((ASMainWindow)this.m_ParentWindow).m_SearchToShow = ASMainWindow.ShowSearchField.HistoryList; if (current.clickCount == 2) { if (this.IsComparableAssetSelected() && (this.m_SelectedGUID == this.m_ChangeLogSelectionGUID)) { this.DoShowDiff(false, this.ChangeLogSelectionRev, -1); } else { this.ShowAssetsHistory(); GUIUtility.ExitGUI(); } } else if (current.button == 1) { GUIUtility.hotControl = 0; r = new Rect(current.mousePosition.x, current.mousePosition.y, 1f, 1f); EditorUtility.DisplayCustomMenu(r, this.m_DropDownMenuItems, -1, new EditorUtility.SelectMenuItemFunction(this.ContextMenuClick), null); } this.DoScroll(); current.Use(); } content.text = folder.files[j].name; content.image = InternalEditorUtility.GetIconForFile(folder.files[j].name); bool flag2 = (this.ChangeLogSelectionRev == this.m_Changesets[changesetIndex].changeset) && (this.m_ChangeLogSelectionGUID == folder.files[j].guid); if (item.boldAssets[index] && !flag2) { GUI.Label(r, string.Empty, ms_Style.ping); } if (Event.current.type == EventType.Repaint) { label.Draw(r, content, false, false, flag2, hasFocus); this.DrawBadge(r, folder.files[j].changeFlags, label, content, GUIClip.visibleRect.width - 150f); } r.y += this.m_RowHeight; } } if (index == num2) { break; } } finally { RectOffset offset3 = ms_Style.label.padding; offset3.left -= 0x10; RectOffset offset4 = ms_Style.boldLabel.padding; offset4.left -= 0x10; } } if (((index == num2) || (num2 >= item.totalLineCount)) && (item.collapsedItemCount != 0)) { r.x += 19f; if (GUI.Button(r, item.collapsedItemCount.ToString() + " more...", ms_Style.foldout)) { GUIUtility.keyboardControl = this.m_HistoryControlID; this.UncollapseListItem(ref item); } } }
public void DoDeletedItemsGUI(ASHistoryWindow parentWin, Rect theRect, GUIStyle s, float offset, float endOffset, bool focused) { Event current = Event.current; Texture2D texture = EditorGUIUtility.FindTexture(EditorResourcesUtility.folderIconName); offset += 3f; Rect position1 = new Rect(this.m_Indent, offset, theRect.width - this.m_Indent, ASHistoryFileView.m_RowHeight); if (current.type == EventType.MouseDown && position1.Contains(current.mousePosition)) { GUIUtility.keyboardControl = this.m_FileViewControlID; this.SelType = ASHistoryFileView.SelectionType.DeletedItemsRoot; this.ScrollToDeletedItem(-1); parentWin.DoLocalSelectionChange(); } position1.width -= position1.x; position1.x = 0.0f; GUIContent content = new GUIContent("Deleted Assets"); content.image = (Texture)texture; int baseIndent = (int)this.m_BaseIndent; s.padding.left = baseIndent; if (current.type == EventType.Repaint) { s.Draw(position1, content, false, false, this.SelType == ASHistoryFileView.SelectionType.DeletedItemsRoot, focused); } Rect position2 = new Rect(this.m_BaseIndent - this.m_FoldoutSize, offset, this.m_FoldoutSize, ASHistoryFileView.m_RowHeight); if (!this.m_DeletedItemsInitialized || this.m_DelPVstate.lv.totalRows != 0) { this.DeletedItemsToggle = GUI.Toggle(position2, this.DeletedItemsToggle, GUIContent.none, ASHistoryFileView.ms_Styles.foldout); } offset += ASHistoryFileView.m_RowHeight; if (!this.DeletedItemsToggle) { return; } int row = this.m_DelPVstate.lv.row; int index1 = 0; int folder1 = -1; int file = -1; int index2 = 0; while ((double)offset <= (double)endOffset && index2 < this.m_DelPVstate.lv.totalRows) { if ((double)offset + (double)ASHistoryFileView.m_RowHeight >= 0.0) { if (folder1 == -1) { this.m_DelPVstate.IndexToFolderAndFile(index2, ref folder1, ref file); } position1 = new Rect(0.0f, offset, (float)Screen.width, ASHistoryFileView.m_RowHeight); ParentViewFolder folder2 = this.m_DelPVstate.folders[folder1]; if (current.type == EventType.MouseDown && position1.Contains(current.mousePosition)) { if (current.button != 1 || this.SelType != ASHistoryFileView.SelectionType.DeletedItems || !this.m_DelPVstate.selectedItems[index1]) { GUIUtility.keyboardControl = this.m_FileViewControlID; this.SelType = ASHistoryFileView.SelectionType.DeletedItems; this.m_DelPVstate.lv.row = index1; ListViewShared.MultiSelection((ListViewShared.InternalListViewState)null, row, this.m_DelPVstate.lv.row, ref this.m_DelPVstate.initialSelectedItem, ref this.m_DelPVstate.selectedItems); this.ScrollToDeletedItem(index1); parentWin.DoLocalSelectionChange(); } if (current.button == 1 && this.SelType == ASHistoryFileView.SelectionType.DeletedItems) { GUIUtility.hotControl = 0; EditorUtility.DisplayCustomMenu(new Rect(current.mousePosition.x, current.mousePosition.y, 1f, 1f), this.dropDownMenuItems, -1, new EditorUtility.SelectMenuItemFunction(this.ContextMenuClick), (object)null); } Event.current.Use(); } int num; if (file != -1) { content.text = folder2.files[file].name; content.image = (Texture)InternalEditorUtility.GetIconForFile(folder2.files[file].name); num = (int)((double)this.m_BaseIndent + (double)this.m_Indent * 2.0); } else { content.text = folder2.name; content.image = (Texture)texture; num = (int)((double)this.m_BaseIndent + (double)this.m_Indent); } s.padding.left = num; if (Event.current.type == EventType.Repaint) { s.Draw(position1, content, false, false, this.m_DelPVstate.selectedItems[index1], focused); } this.m_DelPVstate.NextFileFolder(ref folder1, ref file); ++index1; } ++index2; offset += ASHistoryFileView.m_RowHeight; } }