コード例 #1
0
        public override DragAndDropVisualMode DoDrag(TreeViewItem parentItem, TreeViewItem targetItem, bool perform, DropPosition dropPos)
        {
            if (targetItem == null)
            {
                return(DragAndDropVisualMode.None);
            }

            object savedFilterData = DragAndDrop.GetGenericData(ProjectWindowUtil.k_DraggingFavoriteGenericData);

            // Dragging saved filter
            if (savedFilterData != null)
            {
                int instanceID = (int)savedFilterData;
                if (targetItem is SearchFilterTreeItem && parentItem is SearchFilterTreeItem)// && targetItem.id != draggedInstanceID && parentItem.id != draggedInstanceID)
                {
                    bool validMove = SavedSearchFilters.CanMoveSavedFilter(instanceID, parentItem.id, targetItem.id, dropPos == DropPosition.Below);
                    if (validMove && perform)
                    {
                        SavedSearchFilters.MoveSavedFilter(instanceID, parentItem.id, targetItem.id, dropPos == DropPosition.Below);
                        m_TreeView.SetSelection(new[] { instanceID }, false);
                        m_TreeView.NotifyListenersThatSelectionChanged();
                    }
                    return(validMove ? DragAndDropVisualMode.Copy : DragAndDropVisualMode.None);
                }
                return(DragAndDropVisualMode.None);
            }
            // Dragging of folders into filters
            else
            {
                // Check if we are dragging a single folder
                if (targetItem is SearchFilterTreeItem && parentItem is SearchFilterTreeItem)
                {
                    string genericData = DragAndDrop.GetGenericData(ProjectWindowUtil.k_IsFolderGenericData) as string;
                    if (genericData == "isFolder")
                    {
                        if (perform)
                        {
                            Object[] objs = DragAndDrop.objectReferences;
                            if (objs.Length > 0)
                            {
                                string path = AssetDatabase.GetAssetPath(objs[0].GetInstanceID());
                                if (!string.IsNullOrEmpty(path))
                                {
                                    // TODO: Fix with new AssetDatabase API when it is ready (GetName)
                                    string       folderName   = new DirectoryInfo(path).Name;
                                    SearchFilter searchFilter = new SearchFilter();
                                    searchFilter.folders = new[] { path };
                                    bool addAsChild = targetItem == parentItem;

                                    float previewSize = ProjectBrowserColumnOneTreeViewGUI.GetListAreaGridSize();
                                    int   instanceID  = SavedSearchFilters.AddSavedFilterAfterInstanceID(folderName, searchFilter, previewSize, targetItem.id, addAsChild);
                                    m_TreeView.SetSelection(new[] { instanceID }, false);
                                    m_TreeView.NotifyListenersThatSelectionChanged();
                                }
                                else
                                {
                                    Debug.Log("Could not get asset path from id " + objs[0].GetInstanceID());
                                }
                            }
                        }
                        return(DragAndDropVisualMode.Copy); // Allow dragging folders to filters
                    }
                    return(DragAndDropVisualMode.None);     // Assets that are not folders are not allowed to be dragged to filters
                }
            }
            //  Assets are handled by base
            return(base.DoDrag(parentItem, targetItem, perform, dropPos));
        }
コード例 #2
0
        private static void ShowAssetsPopupMenu <T>(Rect buttonRect, string typeName, SerializedProperty serializedProperty, string fileExtension) where T : Object, new()
        {
            // ISSUE: object of a compiler-generated type is created
            // ISSUE: variable of a compiler-generated type
            AssetPopupBackend.\u003CShowAssetsPopupMenu\u003Ec__AnonStorey76 <T> menuCAnonStorey76 = new AssetPopupBackend.\u003CShowAssetsPopupMenu\u003Ec__AnonStorey76 <T>();
            // ISSUE: reference to a compiler-generated field
            menuCAnonStorey76.typeName = typeName;
            // ISSUE: reference to a compiler-generated field
            menuCAnonStorey76.fileExtension = fileExtension;
            // ISSUE: reference to a compiler-generated field
            menuCAnonStorey76.serializedProperty = serializedProperty;
            GenericMenu genericMenu = new GenericMenu();
            // ISSUE: reference to a compiler-generated field
            // ISSUE: reference to a compiler-generated field
            int num = !(menuCAnonStorey76.serializedProperty.objectReferenceValue != (Object)null) ? 0 : menuCAnonStorey76.serializedProperty.objectReferenceValue.GetInstanceID();

            // ISSUE: reference to a compiler-generated field
            genericMenu.AddItem(new GUIContent("Default"), (num == 0 ? 1 : 0) != 0, new GenericMenu.MenuFunction2(AssetPopupBackend.AssetPopupMenuCallback), (object)new object[2]
            {
                (object)0,
                (object)menuCAnonStorey76.serializedProperty
            });
            HierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);
            // ISSUE: reference to a compiler-generated field
            SearchFilter filter = new SearchFilter()
            {
                classNames = new string[1] {
                    menuCAnonStorey76.typeName
                }
            };

            hierarchyProperty.SetSearchFilter(filter);
            hierarchyProperty.Reset();
            while (hierarchyProperty.Next((int[])null))
            {
                // ISSUE: reference to a compiler-generated field
                genericMenu.AddItem(new GUIContent(hierarchyProperty.name), (hierarchyProperty.instanceID == num ? 1 : 0) != 0, new GenericMenu.MenuFunction2(AssetPopupBackend.AssetPopupMenuCallback), (object)new object[2]
                {
                    (object)hierarchyProperty.instanceID,
                    (object)menuCAnonStorey76.serializedProperty
                });
            }
            // ISSUE: reference to a compiler-generated field
            int classId = BaseObjectTools.StringToClassID(menuCAnonStorey76.typeName);

            if (classId > 0)
            {
                foreach (BuiltinResource builtinResource in EditorGUIUtility.GetBuiltinResourceList(classId))
                {
                    // ISSUE: reference to a compiler-generated field
                    genericMenu.AddItem(new GUIContent(builtinResource.m_Name), (builtinResource.m_InstanceID == num ? 1 : 0) != 0, new GenericMenu.MenuFunction2(AssetPopupBackend.AssetPopupMenuCallback), (object)new object[2]
                    {
                        (object)builtinResource.m_InstanceID,
                        (object)menuCAnonStorey76.serializedProperty
                    });
                }
            }
            genericMenu.AddSeparator(string.Empty);
            // ISSUE: reference to a compiler-generated method
            genericMenu.AddItem(new GUIContent("Create New..."), false, new GenericMenu.MenuFunction(menuCAnonStorey76.\u003C\u003Em__10A));
            genericMenu.DropDown(buttonRect);
        }
コード例 #3
0
 internal void SetSearchFilter(SearchFilter filter)
 {
     this.SetSearchFilterINTERNAL(SearchFilter.Split(filter.nameFilter), filter.classNames, filter.assetLabels, filter.assetBundleNames, filter.versionControlStates, filter.softLockControlStates, filter.referencingInstanceIDs, filter.scenePaths, filter.showAllHits);
 }
コード例 #4
0
 internal static string[] FindAssets(SearchFilter searchFilter)
 {
     return(FindAllAssets(searchFilter).Select(property => property.guid).ToArray());
 }
コード例 #5
0
 public void UpdateFilter(HierarchyType hierarchyType, SearchFilter searchFilter, bool showFoldersFirst)
 {
     UpdateFilter(hierarchyType, searchFilter, showFoldersFirst, SearchService.SearchSessionOptions.Default);
 }
コード例 #6
0
        private static void ShowAssetsPopupMenu <T>(Rect buttonRect, string typeName, SerializedProperty serializedProperty, string fileExtension, string defaultFieldName) where T : UnityEngine.Object, new()
        {
            GenericMenu genericMenu = new GenericMenu();
            int         num         = (!(serializedProperty.objectReferenceValue != null)) ? 0 : serializedProperty.objectReferenceValue.GetInstanceID();
            bool        flag        = false;
            int         num2        = BaseObjectTools.StringToClassID(typeName);

            BuiltinResource[] array = null;
            if (num2 > 0)
            {
                array = EditorGUIUtility.GetBuiltinResourceList(num2);
                BuiltinResource[] array2 = array;
                for (int i = 0; i < array2.Length; i++)
                {
                    BuiltinResource resource = array2[i];
                    if (resource.m_Name == defaultFieldName)
                    {
                        GenericMenu arg_10E_0 = genericMenu;
                        GUIContent  arg_10E_1 = new GUIContent(resource.m_Name);
                        bool        arg_10E_2 = resource.m_InstanceID == num;
                        if (AssetPopupBackend.< > f__mg$cache0 == null)
                        {
                            AssetPopupBackend.< > f__mg$cache0 = new GenericMenu.MenuFunction2(AssetPopupBackend.AssetPopupMenuCallback);
                        }
                        arg_10E_0.AddItem(arg_10E_1, arg_10E_2, AssetPopupBackend.< > f__mg$cache0, new object[]
                        {
                            resource.m_InstanceID,
                            serializedProperty
                        });
                        array = (from x in array
                                 where x != resource
                                 select x).ToArray <BuiltinResource>();
                        flag = true;
                        break;
                    }
                }
            }
            if (!flag)
            {
                GenericMenu arg_190_0 = genericMenu;
                GUIContent  arg_190_1 = new GUIContent(defaultFieldName);
                bool        arg_190_2 = num == 0;
                if (AssetPopupBackend.< > f__mg$cache1 == null)
                {
                    AssetPopupBackend.< > f__mg$cache1 = new GenericMenu.MenuFunction2(AssetPopupBackend.AssetPopupMenuCallback);
                }
                arg_190_0.AddItem(arg_190_1, arg_190_2, AssetPopupBackend.< > f__mg$cache1, new object[]
                {
                    0,
                    serializedProperty
                });
            }
            HierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);
            SearchFilter      searchFilter      = new SearchFilter
            {
                classNames = new string[]
                {
                    typeName
                }
            };

            hierarchyProperty.SetSearchFilter(searchFilter);
            hierarchyProperty.Reset();
            while (hierarchyProperty.Next(null))
            {
                GenericMenu arg_227_0 = genericMenu;
                GUIContent  arg_227_1 = new GUIContent(hierarchyProperty.name);
                bool        arg_227_2 = hierarchyProperty.instanceID == num;
                if (AssetPopupBackend.< > f__mg$cache2 == null)
                {
                    AssetPopupBackend.< > f__mg$cache2 = new GenericMenu.MenuFunction2(AssetPopupBackend.AssetPopupMenuCallback);
                }
                arg_227_0.AddItem(arg_227_1, arg_227_2, AssetPopupBackend.< > f__mg$cache2, new object[]
                {
                    hierarchyProperty.instanceID,
                    serializedProperty
                });
            }
            if (num2 > 0 && array != null)
            {
                BuiltinResource[] array3 = array;
                for (int j = 0; j < array3.Length; j++)
                {
                    BuiltinResource builtinResource = array3[j];
                    GenericMenu     arg_2B1_0       = genericMenu;
                    GUIContent      arg_2B1_1       = new GUIContent(builtinResource.m_Name);
                    bool            arg_2B1_2       = builtinResource.m_InstanceID == num;
                    if (AssetPopupBackend.< > f__mg$cache3 == null)
                    {
                        AssetPopupBackend.< > f__mg$cache3 = new GenericMenu.MenuFunction2(AssetPopupBackend.AssetPopupMenuCallback);
                    }
                    arg_2B1_0.AddItem(arg_2B1_1, arg_2B1_2, AssetPopupBackend.< > f__mg$cache3, new object[]
                    {
                        builtinResource.m_InstanceID,
                        serializedProperty
                    });
                }
            }
            genericMenu.AddSeparator("");
            genericMenu.AddItem(new GUIContent("Create New..."), false, delegate
            {
                T t = Activator.CreateInstance <T>();
                ProjectWindowUtil.CreateAsset(t, "New " + typeName + "." + fileExtension);
                serializedProperty.objectReferenceValue = t;
                serializedProperty.m_SerializedObject.ApplyModifiedProperties();
            });
            genericMenu.DropDown(buttonRect);
        }
コード例 #7
0
        // --------------------
        // Static interface

        // returns is instanceID given to the SavedFilter
        public static int AddSavedFilter(string displayName, SearchFilter filter, float previewSize)
        {
            int instanceID = instance.Add(displayName, filter, previewSize, GetRootInstanceID(), true); // using 0 adds filter after the root

            return(instanceID);
        }
コード例 #8
0
 internal void SetSearchFilter(SearchFilter filter)
 {
     this.SetSearchFilterINTERNAL(SearchFilter.Split(filter.nameFilter), filter.classNames, filter.assetLabels, filter.assetBundleNames, filter.referencingInstanceIDs, filter.showAllHits);
 }
コード例 #9
0
        internal static bool CheckForKeyWords(string searchString, SearchFilter filter, int quote1, int quote2)
        {
            bool flag = false;
            int  num1 = searchString.IndexOf("t:");

            if (num1 == 0)
            {
                string str = searchString.Substring(num1 + 2);
                filter.classNames = new List <string>((IEnumerable <string>)filter.classNames)
                {
                    str
                }.ToArray();
                flag = true;
            }
            int num2 = searchString.IndexOf("l:");

            if (num2 == 0)
            {
                string str = searchString.Substring(num2 + 2);
                filter.assetLabels = new List <string>((IEnumerable <string>)filter.assetLabels)
                {
                    str
                }.ToArray();
                flag = true;
            }
            int num3 = searchString.IndexOf("b:");

            if (num3 == 0)
            {
                string str = searchString.Substring(num3 + 2);
                filter.assetBundleNames = new List <string>((IEnumerable <string>)filter.assetBundleNames)
                {
                    str
                }.ToArray();
                flag = true;
            }
            int num4 = searchString.IndexOf("ref:");

            if (num4 == 0)
            {
                int num5 = 0;
                int num6 = num4 + 3;
                int num7 = searchString.IndexOf(':', num6 + 1);
                if (num7 >= 0)
                {
                    int result;
                    if (int.TryParse(searchString.Substring(num6 + 1, num7 - num6 - 1), out result))
                    {
                        num5 = result;
                    }
                }
                else
                {
                    string assetPath;
                    if (quote1 != -1 && quote2 != -1)
                    {
                        int startIndex = quote1 + 1;
                        int length     = quote2 - quote1 - 1;
                        if (length < 0 || quote2 == -1)
                        {
                            length = searchString.Length - startIndex;
                        }
                        assetPath = "Assets/" + searchString.Substring(startIndex, length);
                    }
                    else
                    {
                        assetPath = "Assets/" + searchString.Substring(num6 + 1);
                    }
                    Object @object = AssetDatabase.LoadMainAssetAtPath(assetPath);
                    if (@object != (Object)null)
                    {
                        num5 = @object.GetInstanceID();
                    }
                }
                filter.referencingInstanceIDs = new int[1] {
                    num5
                };
                flag = true;
            }
            return(flag);
        }
コード例 #10
0
 public static void UpdateExistingSavedFilter(int instanceID, SearchFilter filter, float previewSize)
 {
     instance.UpdateFilter(instanceID, filter, previewSize);
 }
コード例 #11
0
        // private

        static void ShowAssetsPopupMenu <T>(Rect buttonRect, string typeName, SerializedProperty serializedProperty, string fileExtension, string defaultFieldName) where T : Object, new()
        {
            GenericMenu gm = new GenericMenu();

            int selectedInstanceID = serializedProperty.objectReferenceValue != null?serializedProperty.objectReferenceValue.GetInstanceID() : 0;


            bool foundDefaultAsset = false;
            var  type    = UnityEditor.UnityType.FindTypeByName(typeName);
            int  classID = type != null ? type.persistentTypeID : 0;

            BuiltinResource[] resourceList = null;

            // Check the assets for one that matches the default name.
            if (classID > 0)
            {
                resourceList = EditorGUIUtility.GetBuiltinResourceList(classID);
                foreach (var resource in resourceList)
                {
                    if (resource.m_Name == defaultFieldName)
                    {
                        gm.AddItem(new GUIContent(resource.m_Name), resource.m_InstanceID == selectedInstanceID, AssetPopupMenuCallback, new object[] { resource.m_InstanceID, serializedProperty });
                        resourceList      = resourceList.Where(x => x != resource).ToArray();
                        foundDefaultAsset = true;
                        break;
                    }
                }
            }

            // If no defalut asset was found, add defualt null value.
            if (!foundDefaultAsset)
            {
                gm.AddItem(new GUIContent(defaultFieldName), selectedInstanceID == 0, AssetPopupMenuCallback, new object[] { 0, serializedProperty });
            }

            // Add items from asset database
            var property     = new HierarchyProperty(HierarchyType.Assets);
            var searchFilter = new SearchFilter()
            {
                classNames = new[] { typeName }
            };

            property.SetSearchFilter(searchFilter);
            property.Reset();
            while (property.Next(null))
            {
                gm.AddItem(new GUIContent(property.name), property.instanceID == selectedInstanceID, AssetPopupMenuCallback, new object[] { property.instanceID, serializedProperty });
            }

            // Add builtin items, except for the already added default item.
            if (classID > 0 && resourceList != null)
            {
                foreach (var resource in resourceList)
                {
                    gm.AddItem(new GUIContent(resource.m_Name), resource.m_InstanceID == selectedInstanceID, AssetPopupMenuCallback, new object[] { resource.m_InstanceID, serializedProperty });
                }
            }

            // Create item
            gm.AddSeparator("");
            gm.AddItem(EditorGUIUtility.TrTextContent("Create New..."), false, delegate
            {
                var newAsset = Activator.CreateInstance <T>();
                ProjectWindowUtil.CreateAsset(newAsset, "New " + typeName + "." + fileExtension);
                serializedProperty.objectReferenceValue = newAsset;
                serializedProperty.m_SerializedObject.ApplyModifiedProperties();
            });

            gm.DropDown(buttonRect);
        }
コード例 #12
0
        internal static bool CheckForKeyWords(string searchString, SearchFilter filter, int quote1, int quote2)
        {
            bool parsed = false;

            // Support: 't:type' syntax (e.g 't:Texture2D' will show Texture2D objects)
            int index = searchString.IndexOf("t:");

            if (index == 0)
            {
                string        type = searchString.Substring(index + 2);
                List <string> tmp  = new List <string>(filter.classNames);
                tmp.Add(type);
                filter.classNames = tmp.ToArray();
                parsed            = true;
            }

            // Support: 'l:assetlabel' syntax (e.g 'l:architecture' will show assets with AssetLabel 'architecture')
            index = searchString.IndexOf("l:");
            if (index == 0)
            {
                string        label = searchString.Substring(index + 2);
                List <string> tmp   = new List <string>(filter.assetLabels);
                tmp.Add(label);
                filter.assetLabels = tmp.ToArray();
                parsed             = true;
            }

            // Support: 'v:versionState' syntax
            index = searchString.IndexOf("v:");
            if (index >= 0)
            {
                string        versionStateString = searchString.Substring(index + 2);
                List <string> tmp = new List <string>(filter.versionControlStates);
                tmp.Add(versionStateString);
                filter.versionControlStates = tmp.ToArray();
                parsed = true;
            }

            // Support: 's:softLockState' syntax
            index = searchString.IndexOf("s:");
            if (index >= 0)
            {
                string        softLockStateString = searchString.Substring(index + 2);
                List <string> tmp = new List <string>(filter.softLockControlStates);
                tmp.Add(softLockStateString);
                filter.softLockControlStates = tmp.ToArray();
                parsed = true;
            }

            // Support: 'a:area' syntax
            index = searchString.IndexOf("a:");
            if (index >= 0)
            {
                string areaString = searchString.Substring(index + 2);
                if (string.Compare(areaString, "all", true) == 0)
                {
                    filter.searchArea = SearchFilter.SearchArea.AllAssets;
                    parsed            = true;
                }
                else if (string.Compare(areaString, "assets", true) == 0)
                {
                    filter.searchArea = SearchFilter.SearchArea.InAssetsOnly;
                    parsed            = true;
                }
                else if (string.Compare(areaString, "packages", true) == 0)
                {
                    filter.searchArea = SearchFilter.SearchArea.InPackagesOnly;
                    parsed            = true;
                }
            }

            // Support: 'b:assetBundleName' syntax (e.g 'b:materialAssetBundle' will show assets within assetBundle 'materialAssetBundle')
            index = searchString.IndexOf("b:");
            if (index == 0)
            {
                string        assetBundleName = searchString.Substring(index + 2);
                List <string> tmp             = new List <string>(filter.assetBundleNames);
                tmp.Add(assetBundleName);
                filter.assetBundleNames = tmp.ToArray();
                parsed = true;
            }

            // Support: 'ref[:id]:path' syntax (e.g 'ref:1234' will show objects that references the object with instanceID 1234)
            index = searchString.IndexOf("ref:");
            if (index == 0)
            {
                int instanceID = 0;

                int firstColon  = index + 3;
                int secondColon = searchString.IndexOf(':', firstColon + 1);
                if (secondColon >= 0)
                {
                    // Instead of resolving a passed-in pathname to an instance-id, use a supplied one.
                    // The pathname is effectively just a UI hint of whose references we're filtering out.
                    string refString = searchString.Substring(firstColon + 1, secondColon - firstColon - 1);
                    int    id;
                    if (System.Int32.TryParse(refString, out id))
                    {
                        instanceID = id;
                    }
                    //else
                    //  Debug.Log ("Not valid refString to case to Integer " + refString); // outcomment for debugging
                }
                else
                {
                    string assetPath;
                    if (quote1 != -1 && quote2 != -1)
                    {
                        int startIndex = quote1 + 1;
                        int count      = quote2 - quote1 - 1;
                        if (count < 0 || quote2 == -1)
                        {
                            count = searchString.Length - startIndex;
                        }

                        // Strip filepath from quotes
                        assetPath = "Assets/" + searchString.Substring(startIndex, count);
                    }
                    else
                    {
                        // Otherwise use string from colon to end
                        assetPath = "Assets/" + searchString.Substring(firstColon + 1);
                    }

                    Object obj = AssetDatabase.LoadMainAssetAtPath(assetPath);
                    if (obj != null)
                    {
                        instanceID = obj.GetInstanceID();
                    }
                    //else
                    //  Debug.Log ("Not valid assetPath " + assetPath); // outcomment for debugging
                }

                filter.referencingInstanceIDs = new[] { instanceID };
                parsed = true;
            }

            return(parsed);
        }
コード例 #13
0
        // Supports the following syntax:
        // 't:type' syntax (e.g 't:Texture2D' will show Texture2D objects)
        // 'l:assetlabel' syntax (e.g 'l:architecture' will show assets with AssetLabel 'architecture')
        // 'ref[:id]:path' syntax (e.g 'ref:1234' will show objects that references the object with instanceID 1234)
        // 'v:versionState' syntax (e.g 'v:modified' will show objects that are modified locally)
        // 's:softLockState' syntax (e.g 's:inprogress' will show objects that are modified by anyone (except you))
        // 'a:area' syntax (e.g 'a:all' will s search in all assets, 'a:assets' will s search in assets folder only and 'a:packages' will s search in packages folder only)
        internal static bool ParseSearchString(string searchText, SearchFilter filter)
        {
            if (string.IsNullOrEmpty(searchText))
            {
                return(false);
            }

            filter.ClearSearch();

            string searchString = string.Copy(searchText);

            RemoveUnwantedWhitespaces(ref searchString);

            bool parsed = false;

            // Split filter into separate words with space or tab as seperators
            const string kFilterSeparator = " \t,*?";

            // Skip any separators preceding the filter
            int pos = FindFirstPositionNotOf(searchString, kFilterSeparator);

            if (pos == -1)
            {
                pos = 0;
            }
            while (pos < searchString.Length)
            {
                int endpos = searchString.IndexOfAny(kFilterSeparator.ToCharArray(), pos);

                // Check if we have quotes (may be used for pathnames) inbetween start and a /filter-separator/
                int q1 = searchString.IndexOf('"', pos);
                int q2 = -1;
                if (q1 != -1)
                {
                    q2 = searchString.IndexOf('"', q1 + 1);
                    if (q2 != -1)
                    {
                        // Advance to a /filter-separator/ after the quote
                        endpos = searchString.IndexOfAny(kFilterSeparator.ToCharArray(), q2);
                    }
                    else
                    {
                        // In case we can't find another quote, consume the rest of the string
                        endpos = -1;
                    }
                }

                if (endpos == -1)
                {
                    endpos = searchString.Length;
                }

                if (endpos > pos)
                {
                    string token = searchString.Substring(pos, endpos - pos);
                    if (CheckForKeyWords(token, filter, q1, q2))
                    {
                        parsed = true;
                    }
                    else
                    {
                        filter.nameFilter += (string.IsNullOrEmpty(filter.nameFilter) ? "" : " ") + token; // force single space between name tokens
                    }
                }
                pos = endpos + 1;
            }
            return(parsed);
        }
コード例 #14
0
 // Called when the filter has changed
 abstract public void UpdateFilter(HierarchyType hierarchyType, SearchFilter searchFilter, bool showFoldersFirst);
コード例 #15
0
        public static int AddSavedFilterAfterInstanceID(string displayName, SearchFilter filter, float previewSize, int insertAfterID, bool addAsChild)
        {
            int instanceID = instance.Add(displayName, filter, previewSize, insertAfterID, addAsChild);

            return(instanceID);
        }
コード例 #16
0
 // 4.0 interface (made internal for now)
 internal void SetSearchFilter(SearchFilter filter)
 {
     SetSearchFilterImpl(SearchFilter.Split(filter.nameFilter), filter.classNames, filter.assetLabels, filter.assetBundleNames, filter.versionControlStates, filter.softLockControlStates, filter.referencingInstanceIDs, filter.sceneHandles, filter.GlobToRegex().ToArray(), filter.showAllHits);
 }
コード例 #17
0
        public override DragAndDropVisualMode DoDrag(TreeViewItem parentItem, TreeViewItem targetItem, bool perform, TreeViewDragging.DropPosition dropPos)
        {
            if (targetItem == null)
            {
                return(DragAndDropVisualMode.None);
            }
            object genericData = DragAndDrop.GetGenericData(ProjectWindowUtil.k_DraggingFavoriteGenericData);

            if (genericData != null)
            {
                int instanceID = (int)genericData;
                if (targetItem is SearchFilterTreeItem && parentItem is SearchFilterTreeItem)
                {
                    bool flag = SavedSearchFilters.CanMoveSavedFilter(instanceID, parentItem.id, targetItem.id, true);
                    if (flag && perform)
                    {
                        SavedSearchFilters.MoveSavedFilter(instanceID, parentItem.id, targetItem.id, true);
                    }
                    return((!flag) ? DragAndDropVisualMode.None : DragAndDropVisualMode.Copy);
                }
                return(DragAndDropVisualMode.None);
            }
            else
            {
                if (!(targetItem is SearchFilterTreeItem) || !(parentItem is SearchFilterTreeItem))
                {
                    return(base.DoDrag(parentItem, targetItem, perform, dropPos));
                }
                string a = DragAndDrop.GetGenericData(ProjectWindowUtil.k_IsFolderGenericData) as string;
                if (a == "isFolder")
                {
                    if (perform)
                    {
                        UnityEngine.Object[] objectReferences = DragAndDrop.objectReferences;
                        if (objectReferences.Length > 0)
                        {
                            string assetPath = AssetDatabase.GetAssetPath(objectReferences[0].GetInstanceID());
                            if (!string.IsNullOrEmpty(assetPath))
                            {
                                string       name         = new DirectoryInfo(assetPath).Name;
                                SearchFilter searchFilter = new SearchFilter();
                                searchFilter.folders = new string[]
                                {
                                    assetPath
                                };
                                bool  addAsChild       = targetItem == parentItem;
                                float listAreaGridSize = ProjectBrowserColumnOneTreeViewGUI.GetListAreaGridSize();
                                int   activeInstanceID = SavedSearchFilters.AddSavedFilterAfterInstanceID(name, searchFilter, listAreaGridSize, targetItem.id, addAsChild);
                                Selection.activeInstanceID = activeInstanceID;
                            }
                            else
                            {
                                Debug.Log("Could not get asset path from id " + objectReferences[0].GetInstanceID());
                            }
                        }
                    }
                    return(DragAndDropVisualMode.Copy);
                }
                return(DragAndDropVisualMode.None);
            }
        }
コード例 #18
0
 // Called when the filter has changed
 abstract public void UpdateFilter(HierarchyType hierarchyType, SearchFilter searchFilter, bool showFoldersFirst, SearchService.SearchSessionOptions searchSessionOptions);
コード例 #19
0
 internal static IEnumerable <string> GlobToRegex(this SearchFilter filter)
 {
     return(filter.globs.Select(GlobToRegex).Where(IsRegexValid));
 }
コード例 #20
0
        public bool SetNewFilter(SearchFilter newFilter)
        {
            bool changed = false;

            if (newFilter.m_NameFilter != m_NameFilter)
            {
                m_NameFilter = newFilter.m_NameFilter;
                changed      = true;
            }

            if (newFilter.m_ClassNames != m_ClassNames)
            {
                m_ClassNames = newFilter.m_ClassNames;
                changed      = true;
            }

            if (newFilter.m_Folders != m_Folders)
            {
                m_Folders = newFilter.m_Folders;
                changed   = true;
            }
            if (newFilter.m_VersionControlStates != m_VersionControlStates)
            {
                m_VersionControlStates = newFilter.m_VersionControlStates;
                changed = true;
            }
            if (newFilter.m_SoftLockControlStates != m_SoftLockControlStates)
            {
                m_SoftLockControlStates = newFilter.m_SoftLockControlStates;
                changed = true;
            }
            if (newFilter.m_AssetLabels != m_AssetLabels)
            {
                m_AssetLabels = newFilter.m_AssetLabels;
                changed       = true;
            }

            if (newFilter.m_AssetBundleNames != m_AssetBundleNames)
            {
                m_AssetBundleNames = newFilter.m_AssetBundleNames;
                changed            = true;
            }

            if (newFilter.m_ReferencingInstanceIDs != m_ReferencingInstanceIDs)
            {
                m_ReferencingInstanceIDs = newFilter.m_ReferencingInstanceIDs;
                changed = true;
            }

            if (newFilter.m_ScenePaths != m_ScenePaths)
            {
                m_ScenePaths = newFilter.m_ScenePaths;
                changed      = true;
            }

            if (newFilter.m_SearchArea != m_SearchArea)
            {
                m_SearchArea = newFilter.m_SearchArea;
                changed      = true;
            }

            m_ShowAllHits = newFilter.m_ShowAllHits;


            return(changed);
        }
コード例 #21
0
 public override void UpdateFilter(HierarchyType hierarchyType, SearchFilter searchFilter, bool showFoldersFirst)
 {
     ItemsWantedShown = ListMode ? kDefaultRowsShownListMode : (kDefaultRowsShown * m_Grid.columns);
     Assets.Clear();
 }
コード例 #22
0
        public void SetSearchFilter(string searchString, int mode)
        {
            SearchFilter searchFilter = SearchableEditorWindow.CreateFilter(searchString, (SearchableEditorWindow.SearchMode)mode);

            this.SetSearchFilter(searchFilter);
        }
コード例 #23
0
 public static void UpdateExistingSavedFilter(int instanceID, SearchFilter filter, float previewSize)
 {
     ScriptableSingleton <SavedSearchFilters> .instance.UpdateFilter(instanceID, filter, previewSize);
 }
コード例 #24
0
        internal static bool CheckForKeyWords(string searchString, SearchFilter filter, int quote1, int quote2)
        {
            bool result = false;
            int  num    = searchString.IndexOf("t:");

            if (num == 0)
            {
                string item = searchString.Substring(num + 2);
                filter.classNames = new List <string>(filter.classNames)
                {
                    item
                }.ToArray();
                result = true;
            }
            num = searchString.IndexOf("l:");
            if (num == 0)
            {
                string item2 = searchString.Substring(num + 2);
                filter.assetLabels = new List <string>(filter.assetLabels)
                {
                    item2
                }.ToArray();
                result = true;
            }
            num = searchString.IndexOf("v:");
            if (num >= 0)
            {
                string item3 = searchString.Substring(num + 2);
                filter.versionControlStates = new List <string>(filter.versionControlStates)
                {
                    item3
                }.ToArray();
                result = true;
            }
            num = searchString.IndexOf("s:");
            if (num >= 0)
            {
                string item4 = searchString.Substring(num + 2);
                filter.softLockControlStates = new List <string>(filter.softLockControlStates)
                {
                    item4
                }.ToArray();
                result = true;
            }
            num = searchString.IndexOf("b:");
            if (num == 0)
            {
                string item5 = searchString.Substring(num + 2);
                filter.assetBundleNames = new List <string>(filter.assetBundleNames)
                {
                    item5
                }.ToArray();
                result = true;
            }
            num = searchString.IndexOf("ref:");
            if (num == 0)
            {
                int num2 = 0;
                int num3 = num + 3;
                int num4 = searchString.IndexOf(':', num3 + 1);
                if (num4 >= 0)
                {
                    string s = searchString.Substring(num3 + 1, num4 - num3 - 1);
                    int    num5;
                    if (int.TryParse(s, out num5))
                    {
                        num2 = num5;
                    }
                }
                else
                {
                    string assetPath;
                    if (quote1 != -1 && quote2 != -1)
                    {
                        int num6 = quote1 + 1;
                        int num7 = quote2 - quote1 - 1;
                        if (num7 < 0 || quote2 == -1)
                        {
                            num7 = searchString.Length - num6;
                        }
                        assetPath = "Assets/" + searchString.Substring(num6, num7);
                    }
                    else
                    {
                        assetPath = "Assets/" + searchString.Substring(num3 + 1);
                    }
                    UnityEngine.Object @object = AssetDatabase.LoadMainAssetAtPath(assetPath);
                    if (@object != null)
                    {
                        num2 = @object.GetInstanceID();
                    }
                }
                filter.referencingInstanceIDs = new int[]
                {
                    num2
                };
                result = true;
            }
            return(result);
        }
コード例 #25
0
 public static int AddSavedFilter(string displayName, SearchFilter filter, float previewSize)
 {
     return(ScriptableSingleton <SavedSearchFilters> .instance.Add(displayName, filter, previewSize, SavedSearchFilters.GetRootInstanceID(), true));
 }
コード例 #26
0
        void FilterSettingsChanged()
        {
            var filter = new SearchFilter();

            if (m_IsShowingAssets)
            {
                filter.searchArea = SearchFilter.SearchArea.AllAssets;
            }

            filter.SearchFieldStringToFilter(m_SearchFilter);
            if (!string.IsNullOrEmpty(m_RequiredType) && filter.classNames.Length == 0)
            {
                filter.classNames = new[] { m_RequiredType };
            }

            var hierarchyType = m_IsShowingAssets ? HierarchyType.Assets : HierarchyType.GameObjects;

            if (hierarchyType == HierarchyType.GameObjects)
            {
                if (m_ObjectBeingEdited != null)
                {
                    var scene = GetSceneFromObject(m_ObjectBeingEdited);
                    if (scene.IsValid())
                    {
                        // We do not support cross scene references so ensure we only show game objects
                        // from the same scene as the object being edited is part of.
                        // Also don't allow references to other scenes if object being edited
                        // is in a preview scene.
                        if (EditorSceneManager.IsPreviewScene(scene) || EditorSceneManager.preventCrossSceneReferences)
                        {
                            filter.sceneHandles = new[] { scene.handle }
                        }
                        ;
                    }
                }
                else
                {
                    // If we don't know which object is being edited, assume it's one in current stage.
                    PreviewSceneStage previewSceneStage = StageUtility.GetCurrentStage() as PreviewSceneStage;
                    if (previewSceneStage != null)
                    {
                        filter.sceneHandles = new[] { previewSceneStage.scene.handle };
                    }
                }
            }

            if (hierarchyType == HierarchyType.Assets)
            {
                // When AssemblyDefinitionAsset is the required type, don't skip hidden packages
                if (!string.IsNullOrEmpty(m_RequiredType) && m_RequiredType == typeof(AssemblyDefinitionAsset).Name)
                {
                    m_SkipHiddenPackages = false;
                }
                filter.skipHidden = m_SkipHiddenPackages;
            }

            var requiredType = TypeCache.GetTypesDerivedFrom <UnityEngine.Object>()
                               .FirstOrDefault(t => t.Name == m_RequiredType) ?? typeof(UnityObject);

            m_ListArea.InitForSearch(listPosition, hierarchyType, filter, true, s =>
            {
                var asset = AssetDatabase.LoadAssetAtPath(s, requiredType);
                return(asset?.GetInstanceID() ?? 0);
            });
        }
コード例 #27
0
 public static int AddSavedFilterAfterInstanceID(string displayName, SearchFilter filter, float previewSize, int insertAfterID, bool addAsChild)
 {
     return(ScriptableSingleton <SavedSearchFilters> .instance.Add(displayName, filter, previewSize, insertAfterID, addAsChild));
 }
コード例 #28
0
        internal static SearchFilter CreateFilter(string searchString, SearchableEditorWindow.SearchMode searchMode)
        {
            SearchFilter searchFilter = new SearchFilter();
            SearchFilter result;

            if (string.IsNullOrEmpty(searchString))
            {
                result = searchFilter;
            }
            else
            {
                switch (searchMode)
                {
                case SearchableEditorWindow.SearchMode.All:
                    if (!SearchUtility.ParseSearchString(searchString, searchFilter))
                    {
                        searchFilter.nameFilter = searchString;
                        searchFilter.classNames = new string[]
                        {
                            searchString
                        };
                        searchFilter.assetLabels = new string[]
                        {
                            searchString
                        };
                        searchFilter.assetBundleNames = new string[]
                        {
                            searchString
                        };
                        searchFilter.showAllHits = true;
                    }
                    break;

                case SearchableEditorWindow.SearchMode.Name:
                    searchFilter.nameFilter = searchString;
                    break;

                case SearchableEditorWindow.SearchMode.Type:
                    searchFilter.classNames = new string[]
                    {
                        searchString
                    };
                    break;

                case SearchableEditorWindow.SearchMode.Label:
                    searchFilter.assetLabels = new string[]
                    {
                        searchString
                    };
                    break;

                case SearchableEditorWindow.SearchMode.AssetBundleName:
                    searchFilter.assetBundleNames = new string[]
                    {
                        searchString
                    };
                    break;
                }
                result = searchFilter;
            }
            return(result);
        }
コード例 #29
0
        private void FilterSelected(IEnumerable <string> assetBundleNames)
        {
            SearchFilter searchFilter = new SearchFilter();

            if (< > f__am$cache5 == null)
            {