private List <string> GetFilteredAssets(ImportDefinitionProfile profile)
        {
            List <string> associatedAssets = new List <string>();
            List <string> ignorePaths      = new List <string>();
            string        searchFilter;

            List <string> GUIDs;

            // TODO this is probably inefficient, profile and see if there is a more efficient design needed
            if (m_Profile.m_ImportTasks.Count > 0)
            {
                m_Profile.m_ImportTasks[0].GetSearchFilter(out searchFilter, ignorePaths);
                GUIDs = new List <string>(AssetDatabase.FindAssets(searchFilter));

                for (int i = 1; i < m_Profile.m_ImportTasks.Count; ++i)
                {
                    m_Profile.m_ImportTasks[i].GetSearchFilter(out searchFilter, ignorePaths);
                    string[] moduleGUIDs = AssetDatabase.FindAssets(searchFilter);
                    for (int m = GUIDs.Count - 1; m >= 0; --m)
                    {
                        bool guidInModule = false;
                        foreach (string moduleGuiD in moduleGUIDs)
                        {
                            if (GUIDs[m] == moduleGuiD)
                            {
                                guidInModule = true;
                                break;
                            }
                        }
                        if (guidInModule == false)
                        {
                            GUIDs.RemoveAt(m);
                        }
                    }
                }
            }
            else
            {
                GUIDs = new List <string>(AssetDatabase.FindAssets(""));
            }

            //string[] GUIDs = AssetDatabase.FindAssets( typeFilter );
            foreach (var assetGUID in GUIDs)
            {
                string assetPath = AssetDatabase.GUIDToAssetPath(assetGUID);

                // some items may appear twice, due to sub assets, e.g. Sprite
                if (ignorePaths.Contains(assetPath) || associatedAssets.Contains(assetPath))
                {
                    continue;
                }

                if (Filter.Conforms(assetPath, profile.GetFilters()))
                {
                    associatedAssets.Add(assetPath);
                }
            }

            return(associatedAssets);
        }
Esempio n. 2
0
        private List <string> GetFilteredAssets(AuditProfile profile)
        {
            List <string> associatedAssets = new List <string>();
            List <string> ignorePaths      = new List <string>();
            string        typeFilter;

            // TODO see if there is a way to merge
            m_Profile.m_ImporterModule.GetSearchFilter(out typeFilter, ignorePaths);

            string[] GUIDs = AssetDatabase.FindAssets(typeFilter);
            foreach (var assetGUID in GUIDs)
            {
                string assetPath = AssetDatabase.GUIDToAssetPath(assetGUID);

                // some items may appear twice, due to sub assets, e.g. Sprite
                if (ignorePaths.Contains(assetPath) || associatedAssets.Contains(assetPath))
                {
                    continue;
                }

                if (Filter.Conforms(assetPath, profile.m_Filters))
                {
                    associatedAssets.Add(assetPath);
                }
            }

            return(associatedAssets);
        }
        public void PostprocessAsset(ImportContext context, bool checkForConformity = true)
        {
            if (checkForConformity)
            {
                if (m_FilterToFolder)
                {
                    List <Filter> filters = new List <Filter>(m_Filters);
                    filters.Add(new Filter(Filter.ConditionTarget.Directory, Filter.Condition.StartsWith, DirectoryPath));
                    if (Filter.Conforms(context.Importer, filters) == false)
                    {
                        return;
                    }
                }
                else if (Filter.Conforms(context.Importer, m_Filters) == false)
                {
                    return;
                }
            }

            if (m_RunOnImport)
            {
                for (int i = 0; i < m_ImportTasks.Count; ++i)
                {
                    if (m_ImportTasks[i] != null && m_ImportTasks[i].TaskProcessType == BaseImportTask.ProcessingType.Post)
                    {
                        m_ImportTasks[i].Apply(context, this);
                        m_ImportTasks[i].SetManuallyProcessing(context.AssetPath, false);
                    }
                }
            }
            else
            {
                for (int i = 0; i < m_ImportTasks.Count; ++i)
                {
                    if (m_ImportTasks[i] != null && m_ImportTasks[i].IsManuallyProcessing(context.Importer) && m_ImportTasks[i].TaskProcessType == BaseImportTask.ProcessingType.Post)
                    {
                        m_ImportTasks[i].Apply(context, this);
                        m_ImportTasks[i].SetManuallyProcessing(context.AssetPath, false);
                    }
                }
            }
        }
Esempio n. 4
0
        public void ProcessAsset(AssetImporter asset, bool checkForConformity = true)
        {
            if (checkForConformity)
            {
                if (m_FilterToFolder)
                {
                    List <Filter> filters = new List <Filter>(m_Filters);
                    filters.Add(new Filter(Filter.ConditionTarget.Directory, Filter.Condition.StartsWith, DirectoryPath));
                    if (Filter.Conforms(asset, filters) == false)
                    {
                        return;
                    }
                }
                else if (Filter.Conforms(asset, m_Filters) == false)
                {
                    return;
                }
            }

            if (m_RunOnImport)
            {
                for (int i = 0; i < m_ImportTasks.Count; ++i)
                {
                    if (m_ImportTasks[i] != null)
                    {
                        m_ImportTasks[i].Apply(asset, this);
                    }
                }
            }
            else
            {
                for (int i = 0; i < m_ImportTasks.Count; ++i)
                {
                    if (m_ImportTasks[i] != null && m_ImportTasks[i].IsManuallyProcessing(asset))
                    {
                        m_ImportTasks[i].Apply(asset, this);
                    }
                }
            }
        }
        public void PreprocessAsset(ImportContext context, bool checkForConformity = true)
        {
            if (checkForConformity)
            {
                if (m_FilterToFolder)
                {
                    List <Filter> filters = new List <Filter>(m_Filters);
                    filters.Add(new Filter(Filter.ConditionTarget.Directory, Filter.Condition.StartsWith, DirectoryPath));
                    if (Filter.Conforms(context.Importer, filters) == false)
                    {
                        return;
                    }
                }
                else if (Filter.Conforms(context.Importer, m_Filters) == false)
                {
                    return;
                }
            }

            bool saveMeta = false;

            if (m_RunOnImport)
            {
                for (int i = 0; i < m_ImportTasks.Count; ++i)
                {
                    if (m_ImportTasks[i] != null)
                    {
                        m_ImportTasks[i].PreprocessTask(context, this);
                        saveMeta = true;
                        if (m_ImportTasks[i].TaskProcessType == BaseImportTask.ProcessingType.Pre)
                        {
                            m_ImportTasks[i].Apply(context, this);
                            m_ImportTasks[i].SetManuallyProcessing(context.AssetPath, false);
                        }
                    }
                }
            }
            else
            {
                for (int i = 0; i < m_ImportTasks.Count; ++i)
                {
                    if (m_ImportTasks[i] != null && m_ImportTasks[i].IsManuallyProcessing(context.Importer))
                    {
                        m_ImportTasks[i].PreprocessTask(context, this);
                        saveMeta = true;
                        if (m_ImportTasks[i].TaskProcessType == BaseImportTask.ProcessingType.Pre)
                        {
                            m_ImportTasks[i].Apply(context, this);
                            m_ImportTasks[i].SetManuallyProcessing(context.AssetPath, false);
                        }
                    }
                }
            }

            if (saveMeta)
            {
                UserDataSerialization data = UserDataSerialization.Get(context.AssetPath);
                if (data != null)
                {
                    data.SaveMetaData();
                }
            }
        }