Esempio n. 1
0
        private void FolderBrowsing(HierarchyProperty property)
        {
            List <FilteredHierarchy.FilterResult> filterResultList = new List <FilteredHierarchy.FilterResult>();

            foreach (string folder in this.m_SearchFilter.folders)
            {
                int mainAssetInstanceId = AssetDatabase.GetMainAssetInstanceID(folder);
                if (property.Find(mainAssetInstanceId, (int[])null))
                {
                    int   depth = property.depth;
                    int[] array = new int[1] {
                        mainAssetInstanceId
                    };
                    while (property.Next(array) && property.depth > depth)
                    {
                        FilteredHierarchy.FilterResult result = new FilteredHierarchy.FilterResult();
                        this.CopyPropertyData(ref result, property);
                        filterResultList.Add(result);
                        if (property.hasChildren && !property.isFolder)
                        {
                            Array.Resize <int>(ref array, array.Length + 1);
                            array[array.Length - 1] = property.instanceID;
                        }
                    }
                }
            }
            this.m_Results = filterResultList.ToArray();
        }
Esempio n. 2
0
        void SearchInFolders(HierarchyProperty property)
        {
            List <FilterResult> list = new List <FilterResult>();

            string[] baseFolders = ProjectWindowUtil.GetBaseFolders(m_SearchFilter.folders);

            foreach (string folderPath in baseFolders)
            {
                // Ensure we do not have a filter when finding folder
                property.SetSearchFilter(new SearchFilter());

                int folderInstanceID = AssetDatabase.GetMainAssetInstanceID(folderPath);
                if (property.Find(folderInstanceID, null))
                {
                    // Set filter after we found the folder
                    property.SetSearchFilter(m_SearchFilter);
                    int   folderDepth = property.depth;
                    int[] expanded    = null; // enter all children of folder
                    while (property.NextWithDepthCheck(expanded, folderDepth + 1))
                    {
                        FilterResult result = new FilterResult();
                        CopyPropertyData(ref result, property);
                        list.Add(result);
                    }
                }
            }
            m_Results = list.ToArray();
        }
        void DoObjectLabel(Rect rect, string assetPath, GUIStyle style)
        {
            if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && rect.Contains(Event.current.mousePosition))
            {
                // One click shows where the referenced object is
                if (Event.current.clickCount == 1)
                {
                    GUIUtility.keyboardControl = GUIUtility.GetControlID(FocusType.Keyboard);

                    var instanceID = AssetDatabase.GetMainAssetInstanceID(assetPath);
                    EditorGUIUtility.PingObject(instanceID);
                    Event.current.Use();
                }
                // Double click changes selection to referenced object
                else if (Event.current.clickCount == 2)
                {
                    var instanceID = AssetDatabase.GetMainAssetInstanceID(assetPath);
                    Selection.activeInstanceID = instanceID;
                    Event.current.Use();
                    editorWindow.Close();
                    GUIUtility.ExitGUI();
                }
            }

            var icon = AssetDatabase.GetCachedIcon(assetPath);
            var name = System.IO.Path.GetFileNameWithoutExtension(assetPath);

            GUI.Label(rect, EditorGUIUtility.TempContent(name, icon), style);
        }
Esempio n. 4
0
        private void SearchInFolders(HierarchyProperty property)
        {
            List <FilteredHierarchy.FilterResult> list = new List <FilteredHierarchy.FilterResult>();

            string[] baseFolders = ProjectWindowUtil.GetBaseFolders(this.m_SearchFilter.folders);
            string[] array       = baseFolders;
            for (int i = 0; i < array.Length; i++)
            {
                string assetPath = array[i];
                property.SetSearchFilter(new SearchFilter());
                int mainAssetInstanceID = AssetDatabase.GetMainAssetInstanceID(assetPath);
                if (property.Find(mainAssetInstanceID, null))
                {
                    property.SetSearchFilter(this.m_SearchFilter);
                    int   depth    = property.depth;
                    int[] expanded = null;
                    while (property.NextWithDepthCheck(expanded, depth + 1))
                    {
                        FilteredHierarchy.FilterResult item = new FilteredHierarchy.FilterResult();
                        this.CopyPropertyData(ref item, property);
                        list.Add(item);
                    }
                }
            }
            this.m_Results = list.ToArray();
        }
Esempio n. 5
0
        private static string[] SearchInFolders(SearchFilter searchFilter)
        {
            HierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);
            List <string>     list = new List <string>();

            string[] folders = searchFilter.folders;
            for (int i = 0; i < folders.Length; i++)
            {
                string text = folders[i];
                hierarchyProperty.SetSearchFilter(new SearchFilter());
                int mainAssetInstanceID = AssetDatabase.GetMainAssetInstanceID(text);
                if (hierarchyProperty.Find(mainAssetInstanceID, null))
                {
                    hierarchyProperty.SetSearchFilter(searchFilter);
                    int   depth    = hierarchyProperty.depth;
                    int[] expanded = null;
                    while (hierarchyProperty.NextWithDepthCheck(expanded, depth + 1))
                    {
                        list.Add(hierarchyProperty.guid);
                    }
                }
                else
                {
                    Debug.LogWarning("AssetDatabase.FindAssets: Folder not found: '" + text + "'");
                }
            }
            return(list.ToArray());
        }
Esempio n. 6
0
        private void FolderBrowsing(HierarchyProperty property)
        {
            List <FilteredHierarchy.FilterResult> list = new List <FilteredHierarchy.FilterResult>();

            string[] folders = this.m_SearchFilter.folders;
            for (int i = 0; i < folders.Length; i++)
            {
                string assetPath           = folders[i];
                int    mainAssetInstanceID = AssetDatabase.GetMainAssetInstanceID(assetPath);
                if (property.Find(mainAssetInstanceID, null))
                {
                    int   depth = property.depth;
                    int[] array = new int[]
                    {
                        mainAssetInstanceID
                    };
                    while (property.Next(array))
                    {
                        if (property.depth <= depth)
                        {
                            break;
                        }
                        FilteredHierarchy.FilterResult item = new FilteredHierarchy.FilterResult();
                        this.CopyPropertyData(ref item, property);
                        list.Add(item);
                        if (property.hasChildren && !property.isFolder)
                        {
                            Array.Resize <int>(ref array, array.Length + 1);
                            array[array.Length - 1] = property.instanceID;
                        }
                    }
                }
            }
            this.m_Results = list.ToArray();
        }
Esempio n. 7
0
        private static string[] SearchInFolders(SearchFilter searchFilter)
        {
            HierarchyProperty hierarchyProperty = new HierarchyProperty(HierarchyType.Assets);
            List <string>     stringList        = new List <string>();

            foreach (string folder in searchFilter.folders)
            {
                hierarchyProperty.SetSearchFilter(new SearchFilter());
                int mainAssetInstanceId = AssetDatabase.GetMainAssetInstanceID(folder);
                if (hierarchyProperty.Find(mainAssetInstanceId, (int[])null))
                {
                    hierarchyProperty.SetSearchFilter(searchFilter);
                    int   depth    = hierarchyProperty.depth;
                    int[] expanded = (int[])null;
                    while (hierarchyProperty.NextWithDepthCheck(expanded, depth + 1))
                    {
                        stringList.Add(hierarchyProperty.guid);
                    }
                }
                else
                {
                    Debug.LogWarning((object)("AssetDatabase.FindAssets: Folder not found: '" + folder + "'"));
                }
            }
            return(stringList.ToArray());
        }
        AncestorItem[] GetAncestorItems()
        {
            if (!isVariant)
            {
                throw new InvalidOperationException("GetAncestorItems() should only be called for prefab variants");
            }

            var items = new List <AncestorItem>();

            var currentGUID = ObjectToGUID(m_Target);

            while (!string.IsNullOrEmpty(currentGUID))
            {
                var assetPath = AssetDatabase.GUIDToAssetPath(currentGUID);
                Assert.IsNotNull(assetPath);

                items.Add(new AncestorItem {
                    assetPath = assetPath, overrideCount = -1
                });

                var instanceID = AssetDatabase.GetMainAssetInstanceID(assetPath);
                currentGUID = PrefabUtility.GetVariantParentGUID(instanceID);
            }

            return(items.ToArray());
        }
Esempio n. 9
0
        private void FolderBrowsing(HierarchyProperty property)
        {
            List <FilterResult> list = new List <FilterResult>();

            foreach (string str in this.m_SearchFilter.folders)
            {
                int mainAssetInstanceID = AssetDatabase.GetMainAssetInstanceID(str);
                if (property.Find(mainAssetInstanceID, null))
                {
                    int   depth    = property.depth;
                    int[] expanded = new int[] { mainAssetInstanceID };
                    while (property.Next(expanded))
                    {
                        if (property.depth <= depth)
                        {
                            break;
                        }
                        FilterResult result = new FilterResult();
                        this.CopyPropertyData(ref result, property);
                        list.Add(result);
                        if (property.hasChildren && !property.isFolder)
                        {
                            Array.Resize <int>(ref expanded, expanded.Length + 1);
                            expanded[expanded.Length - 1] = property.instanceID;
                        }
                    }
                }
            }
            this.m_Results = list.ToArray();
        }
 private static bool IsPathDataValid(string filePath)
 {
     if (string.IsNullOrEmpty(filePath))
     {
         return(false);
     }
     return(AssetDatabase.GetMainAssetInstanceID(Path.GetDirectoryName(filePath)) != 0);
 }
Esempio n. 11
0
        private static bool IsPathDataValid(string filePath)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                return(false);
            }
            string directoryName       = Path.GetDirectoryName(filePath);
            int    mainAssetInstanceID = AssetDatabase.GetMainAssetInstanceID(directoryName);

            return(mainAssetInstanceID != 0);
        }
Esempio n. 12
0
 public void RevealCurrentLibrary()
 {
     if (m_PresetLibraryFileLocation == PresetFileLocation.PreferencesFolder)
     {
         EditorUtility.RevealInFinder(Path.GetFullPath(pathWithExtension));
     }
     else
     {
         EditorGUIUtility.PingObject(AssetDatabase.GetMainAssetInstanceID(pathWithExtension));
     }
 }
Esempio n. 13
0
 protected override void SyncFakeItem()
 {
     if (!this.m_TreeView.data.HasFakeItem() && this.GetCreateAssetUtility().IsCreatingNewAsset())
     {
         int mainAssetInstanceID = AssetDatabase.GetMainAssetInstanceID(this.GetCreateAssetUtility().folder);
         this.m_TreeView.data.InsertFakeItem(this.GetCreateAssetUtility().instanceID, mainAssetInstanceID, this.GetCreateAssetUtility().originalName, this.GetCreateAssetUtility().icon);
     }
     if (this.m_TreeView.data.HasFakeItem() && !this.GetCreateAssetUtility().IsCreatingNewAsset())
     {
         this.m_TreeView.data.RemoveFakeItem();
     }
 }
Esempio n. 14
0
        override protected void SyncFakeItem()
        {
            if (!m_TreeView.data.HasFakeItem() && GetCreateAssetUtility().IsCreatingNewAsset())
            {
                int parentInstanceID = AssetDatabase.GetMainAssetInstanceID(GetCreateAssetUtility().folder);
                m_TreeView.data.InsertFakeItem(GetCreateAssetUtility().instanceID, parentInstanceID, GetCreateAssetUtility().originalName, GetCreateAssetUtility().icon);
            }

            if (m_TreeView.data.HasFakeItem() && !GetCreateAssetUtility().IsCreatingNewAsset())
            {
                m_TreeView.data.RemoveFakeItem();
            }
        }
Esempio n. 15
0
        static bool IsPathDataValid(string filePath)
        {
            // Ensure some path
            if (string.IsNullOrEmpty(filePath))
            {
                return(false);
            }

            // Ensure valid folder to place the asset in
            string folder     = Path.GetDirectoryName(filePath);
            int    instanceID = AssetDatabase.GetMainAssetInstanceID(folder);

            return(instanceID != 0);
        }
        private static bool IsPathDataValid(string filePath)
        {
            bool result;

            if (string.IsNullOrEmpty(filePath))
            {
                result = false;
            }
            else
            {
                string directoryName       = Path.GetDirectoryName(filePath);
                int    mainAssetInstanceID = AssetDatabase.GetMainAssetInstanceID(directoryName);
                result = (mainAssetInstanceID != 0);
            }
            return(result);
        }
Esempio n. 17
0
        public static int[] GetAncestors(int instanceID)
        {
            int        num2;
            List <int> list = new List <int>();
            int        mainAssetInstanceID = AssetDatabase.GetMainAssetInstanceID(AssetDatabase.GetAssetPath(instanceID));

            if (mainAssetInstanceID != instanceID)
            {
                list.Add(mainAssetInstanceID);
            }
            for (string str = GetContainingFolder(AssetDatabase.GetAssetPath(mainAssetInstanceID)); !string.IsNullOrEmpty(str); str = GetContainingFolder(AssetDatabase.GetAssetPath(num2)))
            {
                num2 = AssetDatabase.GetMainAssetInstanceID(str);
                list.Add(num2);
            }
            return(list.ToArray());
        }
        public static int[] GetAncestors(int instanceID)
        {
            List <int> intList = new List <int>();
            int        mainAssetInstanceId1 = AssetDatabase.GetMainAssetInstanceID(AssetDatabase.GetAssetPath(instanceID));

            if (mainAssetInstanceId1 != instanceID)
            {
                intList.Add(mainAssetInstanceId1);
            }
            int mainAssetInstanceId2;

            for (string containingFolder = ProjectWindowUtil.GetContainingFolder(AssetDatabase.GetAssetPath(mainAssetInstanceId1)); !string.IsNullOrEmpty(containingFolder); containingFolder = ProjectWindowUtil.GetContainingFolder(AssetDatabase.GetAssetPath(mainAssetInstanceId2)))
            {
                mainAssetInstanceId2 = AssetDatabase.GetMainAssetInstanceID(containingFolder);
                intList.Add(mainAssetInstanceId2);
            }
            return(intList.ToArray());
        }
Esempio n. 19
0
        public static int[] GetAncestors(int instanceID)
        {
            List <int> list = new List <int>();
            int        mainAssetInstanceID = AssetDatabase.GetMainAssetInstanceID(AssetDatabase.GetAssetPath(instanceID));
            bool       flag = mainAssetInstanceID != instanceID;

            if (flag)
            {
                list.Add(mainAssetInstanceID);
            }
            string containingFolder = ProjectWindowUtil.GetContainingFolder(AssetDatabase.GetAssetPath(mainAssetInstanceID));

            while (!string.IsNullOrEmpty(containingFolder))
            {
                int mainAssetInstanceID2 = AssetDatabase.GetMainAssetInstanceID(containingFolder);
                list.Add(mainAssetInstanceID2);
                containingFolder = ProjectWindowUtil.GetContainingFolder(AssetDatabase.GetAssetPath(mainAssetInstanceID2));
            }
            return(list.ToArray());
        }
Esempio n. 20
0
        private void SearchInFolders(HierarchyProperty property)
        {
            List <FilteredHierarchy.FilterResult> filterResultList = new List <FilteredHierarchy.FilterResult>();

            foreach (string baseFolder in ProjectWindowUtil.GetBaseFolders(this.m_SearchFilter.folders))
            {
                property.SetSearchFilter(new SearchFilter());
                int mainAssetInstanceId = AssetDatabase.GetMainAssetInstanceID(baseFolder);
                if (property.Find(mainAssetInstanceId, (int[])null))
                {
                    property.SetSearchFilter(this.m_SearchFilter);
                    int   depth    = property.depth;
                    int[] expanded = (int[])null;
                    while (property.NextWithDepthCheck(expanded, depth + 1))
                    {
                        FilteredHierarchy.FilterResult result = new FilteredHierarchy.FilterResult();
                        this.CopyPropertyData(ref result, property);
                        filterResultList.Add(result);
                    }
                }
            }
            this.m_Results = filterResultList.ToArray();
        }