Пример #1
0
        public PipelineBuilder Use <TIn, TOut>(IAssetProcessor <TIn, TOut> processor)
        {
            var input = typeof(TIn);

            _processors[input] = new Processor <TIn, TOut>(processor);
            return(this);
        }
	/// <summary>
	/// 处理图集
	/// </summary>
	private void OnPreprocessSpriteAtlas()
	{
		if (ImportSettingData.Setting.Toggle == false)
			return;

		string importAssetPath = this.assetPath;
		IAssetProcessor processor = ImportSettingData.GetCustomProcessor(importAssetPath);
		if (processor != null)
			processor.OnPreprocessSpriteAtlas(importAssetPath, this.assetImporter);
	}
Пример #3
0
        /// <summary>
        /// 获取资源处理器
        /// </summary>
        /// <param name="importAssetPath">导入的资源路径</param>
        /// <returns>如果该资源的路径没包含在列表里返回NULL</returns>
        public static IAssetProcessor GetCustomProcessor(string importAssetPath)
        {
            // 如果是过滤文件
            string fileName = Path.GetFileNameWithoutExtension(importAssetPath);

            if (fileName.EndsWith("@"))
            {
                return(null);
            }

            // 获取处理器类名
            string className = null;

            for (int i = 0; i < Setting.Elements.Count; i++)
            {
                var element = Setting.Elements[i];
                if (importAssetPath.Contains(element.FolderPath))
                {
                    className = element.ProcessorName;
                    break;
                }
            }
            if (string.IsNullOrEmpty(className))
            {
                return(null);
            }

            // 先从缓存里获取
            IAssetProcessor processor = null;

            if (_cacheProcessor.TryGetValue(className, out processor))
            {
                return(processor);
            }

            // 如果不存在创建处理器
            System.Type type;
            if (_cacheTypes.TryGetValue(className, out type))
            {
                processor = (IAssetProcessor)Activator.CreateInstance(type);
                _cacheProcessor.Add(className, processor);
                return(processor);
            }
            else
            {
                Debug.LogError($"资源处理器类型无效:{className}");
                return(null);
            }
        }
        public void OnPreprocessAudio()
        {
            if (ImportSettingData.Setting.Toggle == false)
            {
                return;
            }

            string          importAssetPath = this.assetPath;
            IAssetProcessor processor       = ImportSettingData.GetCustomProcessor(importAssetPath);

            if (processor != null)
            {
                processor.OnPreprocessAudio(importAssetPath, this.assetImporter);
            }
        }
Пример #5
0
    /// <summary>
    /// 处理图集
    /// </summary>
    private void OnPreprocessSpriteAtlas()
    {
        if (Setting == null)
        {
            LoadSettingFile();
        }
        if (Setting == null || Setting.Toggle == false)
        {
            return;
        }

        string          importAssetPath = this.assetPath;
        IAssetProcessor processor       = GetCustomProcessor(importAssetPath);

        if (processor != null)
        {
            processor.OnPreprocessSpriteAtlas(importAssetPath, this.assetImporter);
        }
    }
Пример #6
0
 public Processor(IAssetProcessor <TIn, TOut> processor)
 {
     _processor = processor;
 }
Пример #7
0
 public static IAssetProcessor <TIn, TOut> Then <TIn, TIntermediate, TOut>(
     this IAssetProcessor <TIn, TIntermediate> first, IAssetProcessor <TIntermediate, TOut> second)
 {
     return(new MergedAssetProcessor <TIn, TIntermediate, TOut>(first, second));
 }
Пример #8
0
 public MergedAssetProcessor(IAssetProcessor <TIn, TIntermediate> first, IAssetProcessor <TIntermediate, TOut> second)
 {
     _first  = first;
     _second = second;
 }