public override async Task <bool> Process(PipeContext context)
    {
        if (context == null)
        {
            throw new System.ArgumentNullException("context");
        }

        if (context.assets == null)
        {
            context.assets = new List <AssetEntry>();
        }

        List <string> files = CollectAssetsToBuild(TargetPath);

        for (int i = 0; i < files.Count; i++)
        {
            string assetPath = files[i];
            Object obj       = AssetDatabase.LoadAssetAtPath(assetPath, typeof(Object));
            var    type      = PipleUtility.GetAssetType(obj);

            context.assets.Add(new AssetEntry()
            {
                assetPath = assetPath,
                type      = type
            });
        }

        await Task.FromResult(true);

        return(true);
    }
Пример #2
0
    public override async Task <bool> Process(PipeContext context)
    {
        if (context == null)
        {
            throw new System.ArgumentNullException("context");
        }

        var assets = context.assets;

        if (assets == null)
        {
            return(true);
        }

        AssetEntry[] origins = assets.ToArray();

        for (int i = 0; i < origins.Length; i++)
        {
            var entry = origins[i];
            if (entry == null)
            {
                continue;
            }

            var assetPath = entry.assetPath;
            var deps      = AssetDatabase.GetDependencies(assetPath, Recursive);
            for (int j = 0; j < deps.Length; j++)
            {
                var depAssetPath = deps[j];
                if (depAssetPath.Equals(assetPath))
                {
                    continue;
                }

                if (assets.Any(v => v.assetPath.Equals(depAssetPath)))
                {
                    continue;
                }

                var depObj = AssetDatabase.LoadAssetAtPath(depAssetPath, typeof(Object));
                if (depObj == null)
                {
                    continue;
                }

                if (depObj is MonoScript)
                {
                    continue;
                }

                assets.Add(new AssetEntry()
                {
                    assetPath = depAssetPath,
                    type      = PipleUtility.GetAssetType(depObj)
                });
            }
        }

        await Task.FromResult(true);

        return(true);
    }