Пример #1
0
 /// <summary>
 /// 加载配置文件
 /// </summary>
 private static void LoadSettingData()
 {
     // 加载配置文件
     _setting = AssetDatabase.LoadAssetAtPath <AssetBundleCollectorSetting>(EditorDefine.AssetBundleCollectorSettingFilePath);
     if (_setting == null)
     {
         Debug.LogWarning($"Create new {nameof(AssetBundleCollectorSetting)}.asset : {EditorDefine.AssetBundleCollectorSettingFilePath}");
         _setting = ScriptableObject.CreateInstance <AssetBundleCollectorSetting>();
         EditorTools.CreateFileDirectory(EditorDefine.AssetBundleCollectorSettingFilePath);
         AssetDatabase.CreateAsset(Setting, EditorDefine.AssetBundleCollectorSettingFilePath);
         AssetDatabase.SaveAssets();
         AssetDatabase.Refresh();
     }
     else
     {
         Debug.Log($"Load {nameof(AssetBundleCollectorSetting)}.asset ok");
     }
 }
Пример #2
0
        /// <summary>
        /// 加载配置文件
        /// </summary>
        private static void LoadSettingData()
        {
            // 加载配置文件
            _setting = AssetDatabase.LoadAssetAtPath <AssetBundleCollectorSetting>(EditorDefine.AssetBundleCollectorSettingFilePath);
            if (_setting == null)
            {
                Debug.LogWarning($"Create new {nameof(AssetBundleCollectorSetting)}.asset : {EditorDefine.AssetBundleCollectorSettingFilePath}");
                _setting = ScriptableObject.CreateInstance <AssetBundleCollectorSetting>();
                EditorTools.CreateFileDirectory(EditorDefine.AssetBundleCollectorSettingFilePath);
                AssetDatabase.CreateAsset(Setting, EditorDefine.AssetBundleCollectorSettingFilePath);
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
            }
            else
            {
                Debug.Log($"Load {nameof(AssetBundleCollectorSetting)}.asset ok");
            }

            // 清空缓存集合
            _cacheTypes.Clear();
            _cacheCollector.Clear();

            // 获取所有资源收集器类型
            List <Type> types = AssemblyUtility.GetAssignableTypes(AssemblyUtility.UnityDefaultAssemblyEditorName, typeof(IAssetCollector));

            types.Add(typeof(LabelNone));
            types.Add(typeof(LabelByFilePath));
            types.Add(typeof(LabelByFolderPath));
            for (int i = 0; i < types.Count; i++)
            {
                Type type = types[i];
                if (_cacheTypes.ContainsKey(type.Name) == false)
                {
                    _cacheTypes.Add(type.Name, type);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// 加载配置文件
        /// </summary>
        private static void LoadSettingData()
        {
            // 加载配置文件
            _setting = AssetDatabase.LoadAssetAtPath <AssetBundleCollectorSetting>(EditorDefine.AssetBundleCollectorSettingFilePath);
            if (_setting == null)
            {
                Debug.LogWarning($"Create new {nameof(AssetBundleCollectorSetting)}.asset : {EditorDefine.AssetBundleCollectorSettingFilePath}");
                _setting = ScriptableObject.CreateInstance <AssetBundleCollectorSetting>();
                EditorTools.CreateFileDirectory(EditorDefine.AssetBundleCollectorSettingFilePath);
                AssetDatabase.CreateAsset(Setting, EditorDefine.AssetBundleCollectorSettingFilePath);
                AssetDatabase.SaveAssets();
                AssetDatabase.Refresh();
            }
            else
            {
                Debug.Log($"Load {nameof(AssetBundleCollectorSetting)}.asset ok");
            }

            // 收集器类型
            {
                // 清空缓存集合
                _cacheLabelTypes.Clear();
                _cacheLabelInstance.Clear();

                // 获取所有类型
                List <Type> types = new List <Type>(100)
                {
                    typeof(LabelByFilePath),
                    typeof(LabelByFolderPath)
                };
                var customTypes = AssemblyUtility.GetAssignableTypes(AssemblyUtility.UnityDefaultAssemblyEditorName, typeof(IBundleLabel));
                types.AddRange(customTypes);
                for (int i = 0; i < types.Count; i++)
                {
                    Type type = types[i];
                    if (_cacheLabelTypes.ContainsKey(type.Name) == false)
                    {
                        _cacheLabelTypes.Add(type.Name, type);
                    }
                }
            }

            // 过滤器类型
            {
                // 清空缓存集合
                _cacheFilterTypes.Clear();
                _cacheFilterInstance.Clear();

                // 获取所有类型
                List <Type> types = new List <Type>(100)
                {
                    typeof(SearchAll),
                    typeof(SearchScene),
                    typeof(SearchPrefab),
                    typeof(SearchSprite)
                };
                var customTypes = AssemblyUtility.GetAssignableTypes(AssemblyUtility.UnityDefaultAssemblyEditorName, typeof(ISearchFilter));
                types.AddRange(customTypes);
                for (int i = 0; i < types.Count; i++)
                {
                    Type type = types[i];
                    if (_cacheFilterTypes.ContainsKey(type.Name) == false)
                    {
                        _cacheFilterTypes.Add(type.Name, type);
                    }
                }
            }
        }