internal static void GetAncestors(int instanceID, HashSet <int> ancestors) { // Ensure we handle packages root folder if (instanceID == ProjectBrowser.kPackagesFolderInstanceId) { return; } // Ensure we add the main asset as ancestor if input is a subasset int mainAssetInstanceID = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(AssetDatabase.GetAssetPath(instanceID)); bool isSubAsset = mainAssetInstanceID != instanceID; if (isSubAsset) { ancestors.Add(mainAssetInstanceID); } // Find ancestors of main aset string currentFolderPath = GetContainingFolder(AssetDatabase.GetAssetPath(mainAssetInstanceID)); while (!string.IsNullOrEmpty(currentFolderPath)) { int currentInstanceID = ProjectBrowser.GetFolderInstanceID(currentFolderPath); ancestors.Add(currentInstanceID); currentFolderPath = GetContainingFolder(AssetDatabase.GetAssetPath(currentInstanceID)); } }
// Can be used to ensure repaint of the ProjectWindow. public static void RepaintProjectWindow() { foreach (ProjectBrowser pb in ProjectBrowser.GetAllProjectBrowsers()) { pb.Repaint(); } }
[RequiredByNativeCode] public static void FocusProjectWindow() { ProjectBrowser prjBrowser = null; var focusedView = GUIView.focusedView as HostView; if (focusedView != null && focusedView.actualView is ProjectBrowser) { prjBrowser = focusedView.actualView as ProjectBrowser; } if (prjBrowser == null) { UnityEngine.Object[] wins = Resources.FindObjectsOfTypeAll(typeof(ProjectBrowser)); if (wins.Length > 0) { prjBrowser = wins[0] as ProjectBrowser; } } if (prjBrowser != null) { prjBrowser.Focus(); var commandEvent = EditorGUIUtility.CommandEvent("FocusProjectWindow"); prjBrowser.SendEvent(commandEvent); } }
public static void OnAfterAssemblyReload() { foreach (ProjectBrowser current in ProjectBrowser.GetAllProjectBrowsers()) { current.Repaint(); } }
public static IEnumerable <SearchItem> CurrentFolder(SearchExpressionContext c) { string currentSelectedPath = string.Empty; if (ProjectBrowser.s_LastInteractedProjectBrowser) { if (ProjectBrowser.s_LastInteractedProjectBrowser.IsTwoColumns()) { currentSelectedPath = ProjectBrowser.s_LastInteractedProjectBrowser.GetActiveFolderPath() ?? string.Empty; } else { currentSelectedPath = ProjectBrowser.GetSelectedPath() ?? string.Empty; var isFile = File.Exists(currentSelectedPath); var isDirectory = Directory.Exists(currentSelectedPath); if (!isDirectory && !isFile) { currentSelectedPath = string.Empty; } else if (isFile) { currentSelectedPath = Path.GetDirectoryName(currentSelectedPath) ?? string.Empty; } } } if (!string.IsNullOrEmpty(currentSelectedPath)) { currentSelectedPath = currentSelectedPath.ConvertSeparatorsToUnity(); } yield return(SearchExpression.CreateItem(currentSelectedPath, c.ResolveAlias("CurrentFolder"))); }
public static void FocusProjectWindow() { ProjectBrowser prjBrowser = null; var focusedView = GUIView.focusedView as HostView; if (focusedView != null && focusedView.actualView is ProjectBrowser) { prjBrowser = (ProjectBrowser)focusedView.actualView; } if (prjBrowser == null) { var wins = Resources.FindObjectsOfTypeAll(typeof(ProjectBrowser)); if (wins.Length > 0) { prjBrowser = wins[0] as ProjectBrowser; } } if (prjBrowser != null) { prjBrowser.Focus(); // This line is to circumvent a limitation where a tabbed window can't be directly targeted by a command: only the focused tab can. var commandEvent = EditorGUIUtility.CommandEvent("FocusProjectWindow"); prjBrowser.SendEvent(commandEvent); } }
public static void RepaintProjectWindow() { foreach (ProjectBrowser current in ProjectBrowser.GetAllProjectBrowsers()) { current.Repaint(); } }
protected override void RenameEnded() { int userData = base.GetRenameOverlay().userData; ProjectBrowser.ItemType itemType = ProjectBrowser.GetItemType(userData); if (this.m_IsCreatingSavedFilter) { this.m_IsCreatingSavedFilter = false; if (base.GetRenameOverlay().userAcceptedRename) { SavedSearchFilters.SetName(userData, base.GetRenameOverlay().name); int[] selectedIDs = new int[] { userData }; base.m_TreeView.SetSelection(selectedIDs, true); } else { SavedSearchFilters.RemoveSavedFilter(userData); } } else if (itemType == ProjectBrowser.ItemType.SavedFilter) { if (base.GetRenameOverlay().userAcceptedRename) { SavedSearchFilters.SetName(userData, base.GetRenameOverlay().name); } } else { base.RenameEnded(); if (base.GetRenameOverlay().userAcceptedRename) { base.m_TreeView.NotifyListenersThatSelectionChanged(); } } }
public LevelBrowserDialog(string file) { InitializeComponent(); filename = file; ProjectBrowser.RefreshList(); ProjectBrowser.SetSelection(filename); }
private void HandleCommandEvents(int treeViewKeyboardControlID) { if (GUIUtility.keyboardControl != treeViewKeyboardControlID) { return; } EventType type = Event.current.type; if (type == EventType.ExecuteCommand || type == EventType.ValidateCommand) { bool flag = type == EventType.ExecuteCommand; if (Event.current.commandName == "Delete" || Event.current.commandName == "SoftDelete") { Event.current.Use(); if (flag) { ProjectBrowser.DeleteSelectedAssets(true); } } else if (Event.current.commandName == "Duplicate") { Event.current.Use(); if (flag) { ProjectWindowUtil.DuplicateSelectedAssets(); } } } }
private void HandleCommandEvents(int treeViewKeyboardControlID) { if (GUIUtility.keyboardControl == treeViewKeyboardControlID) { EventType type = Event.current.type; switch (type) { case EventType.ExecuteCommand: case EventType.ValidateCommand: { bool flag = type == EventType.ExecuteCommand; if ((Event.current.commandName == "Delete") || (Event.current.commandName == "SoftDelete")) { Event.current.Use(); if (flag) { ProjectBrowser.DeleteSelectedAssets(true); } } else if (Event.current.commandName == "Duplicate") { Event.current.Use(); if (flag) { ProjectWindowUtil.DuplicateSelectedAssets(); } } break; } } } }
/// <summary> /// 在主窗体上显示Project的Tree /// </summary> /// <returns></returns> private void ShowProjectTree() { ProjectBrowser projectBrowser = new ProjectBrowser(); projectBrowser.ViewProject(ProjectService.CurrentProject); projectWindow.Content = projectBrowser; }
public void ShowInFavoriteSearchFilters() { if (SavedSearchFilters.GetRootInstanceID() == 0) { SavedSearchFilters.AddInitializedListener(ShowInFavoriteSearchFilters); return; } SavedSearchFilters.RemoveInitializedListener(ShowInFavoriteSearchFilters); int prevInstanceID = 0; foreach (var filter in filters) { int instanceID = SavedSearchFilters.GetFilterInstanceID(filter[0], filter[1]); if (instanceID == 0) { SearchFilter searchFilter = SearchFilter.CreateSearchFilterFromString(filter[1]); if (prevInstanceID == 0) { prevInstanceID = SavedSearchFilters.AddSavedFilter(filter[0], searchFilter, 64); } else { prevInstanceID = SavedSearchFilters.AddSavedFilterAfterInstanceID(filter[0], searchFilter, 64, prevInstanceID, false); } } } SavedSearchFilters.RefreshSavedFilters(); foreach (ProjectBrowser pb in ProjectBrowser.GetAllProjectBrowsers()) { pb.Repaint(); } }
public void ShowInFavoriteSearchFilters() { if (SavedSearchFilters.GetRootInstanceID() == 0) { SavedSearchFilters.AddInitializedListener(new Action(this.ShowInFavoriteSearchFilters)); } else { SavedSearchFilters.RemoveInitializedListener(new Action(this.ShowInFavoriteSearchFilters)); int num = 0; foreach (string[] current in this.filters) { if (SavedSearchFilters.GetFilterInstanceID(current[0], current[1]) == 0) { SearchFilter filter = SearchFilter.CreateSearchFilterFromString(current[1]); if (num == 0) { num = SavedSearchFilters.AddSavedFilter(current[0], filter, 64f); } else { num = SavedSearchFilters.AddSavedFilterAfterInstanceID(current[0], filter, 64f, num, false); } } } SavedSearchFilters.RefreshSavedFilters(); foreach (ProjectBrowser current2 in ProjectBrowser.GetAllProjectBrowsers()) { current2.Repaint(); } } }
public static void StartNameEditingIfProjectWindowExists(int instanceID, EndNameEditAction endAction, string pathName, Texture2D icon, string resourceFile, bool selectAssetBeingCreated) { // instanceID 0 is used for assets that haven't been imported, which can conflict with // asset under creations, which might also use instanceID 0. To avoid this conflict the instanceID // is changed if 0. if (instanceID == 0) { instanceID = ProjectBrowser.kAssetCreationInstanceID_ForNonExistingAssets; } ProjectBrowser pb = GetProjectBrowserIfExists(); if (pb) { pb.Focus(); pb.BeginPreimportedNameEditing(instanceID, endAction, pathName, icon, resourceFile, selectAssetBeingCreated); pb.Repaint(); } else { if (!pathName.StartsWith("assets/", StringComparison.CurrentCultureIgnoreCase)) { pathName = "Assets/" + pathName; } EndNameEditAction(endAction, instanceID, pathName, resourceFile, true); if (selectAssetBeingCreated) { Selection.activeObject = EditorUtility.InstanceIDToObject(instanceID); } } }
private void ShowGeneral() { GUILayout.Space(10f); this.m_AutoRefresh = EditorGUILayout.Toggle("Auto Refresh", this.m_AutoRefresh, new GUILayoutOption[0]); this.m_ReopenLastUsedProjectOnStartup = EditorGUILayout.Toggle("Load Previous Project on Startup", this.m_ReopenLastUsedProjectOnStartup, new GUILayoutOption[0]); bool compressAssetsOnImport = this.m_CompressAssetsOnImport; this.m_CompressAssetsOnImport = EditorGUILayout.Toggle("Compress Assets on Import", compressAssetsOnImport, new GUILayoutOption[0]); if (GUI.changed && this.m_CompressAssetsOnImport != compressAssetsOnImport) { Unsupported.SetApplicationSettingCompressAssetsOnImport(this.m_CompressAssetsOnImport); } if (Application.platform == RuntimePlatform.OSXEditor) { this.m_UseOSColorPicker = EditorGUILayout.Toggle("OS X Color Picker", this.m_UseOSColorPicker, new GUILayoutOption[0]); } bool flag = Application.HasProLicense(); EditorGUI.BeginDisabledGroup(!flag); this.m_EnableEditorAnalytics = !EditorGUILayout.Toggle("Disable Editor Analytics (Pro Only)", !this.m_EnableEditorAnalytics, new GUILayoutOption[0]); if (!flag && !this.m_EnableEditorAnalytics) { this.m_EnableEditorAnalytics = true; } EditorGUI.EndDisabledGroup(); bool flag2 = false; EditorGUI.BeginChangeCheck(); this.m_ShowAssetStoreSearchHits = EditorGUILayout.Toggle("Show Asset Store search hits", this.m_ShowAssetStoreSearchHits, new GUILayoutOption[0]); if (EditorGUI.EndChangeCheck()) { flag2 = true; } this.m_VerifySavingAssets = EditorGUILayout.Toggle("Verify Saving Assets", this.m_VerifySavingAssets, new GUILayoutOption[0]); EditorGUI.BeginDisabledGroup(!flag); int num = EditorGUILayout.Popup("Editor Skin", EditorGUIUtility.isProSkin ? 1 : 0, new string[] { "Light", "Dark" }, new GUILayoutOption[0]); if ((EditorGUIUtility.isProSkin ? 1 : 0) != num) { InternalEditorUtility.SwitchSkinAndRepaintAllViews(); } EditorGUI.EndDisabledGroup(); bool allowAlphaNumericHierarchy = this.m_AllowAlphaNumericHierarchy; this.m_AllowAlphaNumericHierarchy = EditorGUILayout.Toggle("Enable Alpha Numeric Sorting", this.m_AllowAlphaNumericHierarchy, new GUILayoutOption[0]); this.ApplyChangesToPrefs(); if (allowAlphaNumericHierarchy != this.m_AllowAlphaNumericHierarchy) { EditorApplication.DirtyHierarchyWindowSorting(); } if (flag2) { ProjectBrowser.ShowAssetStoreHitsWhileSearchingLocalAssetsChanged(); } }
private void RepaintProjectBrowsers() { foreach (ProjectBrowser pb in ProjectBrowser.GetAllProjectBrowsers()) { pb.RefreshSearchIfFilterContains("s:"); pb.Repaint(); } }
private void RepaintProjectBrowsers() { foreach (ProjectBrowser current in ProjectBrowser.GetAllProjectBrowsers()) { current.RefreshSearchIfFilterContains("s:"); current.Repaint(); } }
public void HideFromFavoriteSearchFilters() { SavedSearchFilters.RefreshSavedFilters(); foreach (ProjectBrowser current in ProjectBrowser.GetAllProjectBrowsers()) { current.Repaint(); } }
private static bool IsTwoColumns() { if (_browser == null) { _browser = ProjectBrowser.Create(); } return(_browser.IsTwoColumns()); }
protected override void Apply() { base.Apply(); this.WriteSettingsToBackend(); foreach (ProjectBrowser current in ProjectBrowser.GetAllProjectBrowsers()) { current.Repaint(); } }
internal static void FrameObjectInProjectWindow(int instanceID) { ProjectBrowser projectBrowserIfExists = ProjectWindowUtil.GetProjectBrowserIfExists(); if (projectBrowserIfExists) { projectBrowserIfExists.FrameObject(instanceID, false); } }
internal static void FrameObjectInProjectWindow(int instanceID) { ProjectBrowser pb = GetProjectBrowserIfExists(); if (pb) { pb.FrameObject(instanceID, false); } }
internal override void Apply() { base.Apply(); this.SyncSettingsToBackend(); foreach (ProjectBrowser browser in ProjectBrowser.GetAllProjectBrowsers()) { browser.Repaint(); } }
private float GetTopPixelOfRow(int row, List <TreeViewItem> rows) { float num = (float)row * this.k_LineHeight; if (ProjectBrowser.GetItemType(rows[row].id) == ProjectBrowser.ItemType.Asset) { num += 15f; } return(num); }
internal static string GetActiveFolderPath() { ProjectBrowser projectBrowserIfExists = ProjectWindowUtil.GetProjectBrowserIfExists(); if (projectBrowserIfExists == null) { return("Assets"); } return(projectBrowserIfExists.GetActiveFolderPath()); }
/// <summary> /// <para>Can be used to ensure repaint of the ProjectWindow.</para> /// </summary> public static void RepaintProjectWindow() { using (List <ProjectBrowser> .Enumerator enumerator = ProjectBrowser.GetAllProjectBrowsers().GetEnumerator()) { while (enumerator.MoveNext()) { enumerator.Current.Repaint(); } } }
internal static void FrameObjectInProjectWindow(int instanceID) { ProjectBrowser projectBrowserIfExists = ProjectWindowUtil.GetProjectBrowserIfExists(); if (!(bool)((UnityEngine.Object)projectBrowserIfExists)) { return; } projectBrowserIfExists.FrameObject(instanceID, false); }
public static void OnAfterAssemblyReload() { using (List <ProjectBrowser> .Enumerator enumerator = ProjectBrowser.GetAllProjectBrowsers().GetEnumerator()) { while (enumerator.MoveNext()) { enumerator.Current.Repaint(); } } }
public void DeleteAudioMixerCallback(object obj) { AudioMixerController controller = (AudioMixerController)obj; if (controller != null) { Selection.activeObject = controller; ProjectBrowser.DeleteSelectedAssets(true); } }
internal static void Show(string folder, string currentSubFolder, Rect activatorRect, ProjectBrowser caller) { m_Caller = caller; string[] subFolders = AssetDatabase.GetSubFolders(folder); GenericMenu menu = new GenericMenu(); if (subFolders.Length >= 0) { currentSubFolder = Path.GetFileName(currentSubFolder); foreach (string str in subFolders) { string fileName = Path.GetFileName(str); menu.AddItem(new GUIContent(fileName), fileName == currentSubFolder, new GenericMenu.MenuFunction(new ProjectBrowser.BreadCrumbListMenu(str).SelectSubFolder)); menu.ShowAsContext(); } } else { menu.AddDisabledItem(new GUIContent("No sub folders...")); } menu.DropDown(activatorRect); }