Example #1
0
    public override void Build(BuildTarget target, Model.NodeData node, IEnumerable <PerformGraph.AssetGroups> incoming,
                               IEnumerable <Model.ConnectionData> connectionsToOutput, PerformGraph.Output outputFunc,
                               Action <Model.NodeData, string, float> progressFunc)
    {
        var customManifest    = new CustomManifest();
        var assetsToBundleMap = new Dictionary <string, string>();

        foreach (var assetGroups in incoming)
        {
            foreach (var ag in assetGroups.assetGroups)
            {
                var assetInfos = ag.Value;
                ProcessingAssetInfos(target, assetInfos, assetsToBundleMap, customManifest);
            }
        }

        foreach (var assetToBundle in assetsToBundleMap)
        {
            var assetInfo = new AssetInBundleInfo();
            assetInfo.Name             = assetToBundle.Key;
            assetInfo.GameAssetTypeTag = GetAssetType(assetToBundle.Key).ToString();

            foreach (var assetDependency in AssetDatabase.GetDependencies(assetToBundle.Key))
            {
                if (assetDependency == assetToBundle.Key)
                {
                    continue;
                }

                if (assetsToBundleMap.ContainsKey(assetDependency))
                {
                    var bundleDep = assetsToBundleMap[assetDependency];

                    if (!assetInfo.Dependencies.Contains(bundleDep) && bundleDep != assetToBundle.Value)
                    {
                        assetInfo.Dependencies.Add(bundleDep);
                    }
                }
            }

            customManifest.AssetInfos.Add(assetInfo.Name, assetInfo);
        }

        var jsonSerializer =
            new JsonSerializer(new JsonSerializerSettings {
            Formatting = Formatting.Indented
        }, Encoding.UTF8);
        var manifestAsJson = jsonSerializer.SerializeString(customManifest);

        var path = GetCustomManifestPath(target, node);

        File.WriteAllText(path, manifestAsJson);
    }
    private void CopyManifest(AssetBundleManifest manifest)
    {
        if (_manifestCachePath == null)
        {
            throw new Exception("ManifestCachePath is null");
        }

        var jsonSerializer = new JsonSerializer(new JsonSerializerSettings
        {
            Formatting = Formatting.Indented
        }, Encoding.UTF8);
        var manifestAsJson = jsonSerializer.SerializeString(manifest);

        var pathToCopy = Path.Combine(Directory.GetParent(Application.dataPath).ToString(), _manifestCachePath.path);

        File.WriteAllText(pathToCopy, manifestAsJson);
    }
    public override void Build(BuildTarget target, Model.NodeData node, IEnumerable <PerformGraph.AssetGroups> incoming,
                               IEnumerable <Model.ConnectionData> connectionsToOutput, PerformGraph.Output outputFunc,
                               Action <Model.NodeData, string, float> progressFunc)
    {
        var customManifest = new AssetsManifest <AssetInfo>();

        foreach (var assetGroups in incoming)
        {
            foreach (var ag in assetGroups.assetGroups)
            {
                var assetInfos = ag.Value;
                ProcessingAssetInfos(assetInfos, customManifest);
            }
        }

        var jsonSerializer =
            new JsonSerializer(new JsonSerializerSettings {
            Formatting = Formatting.Indented
        }, Encoding.UTF8);
        var manifestAsJson = jsonSerializer.SerializeString(customManifest);

        var rootFolder = Path.Combine(Directory.GetParent(Application.dataPath).ToString(),
                                      _manifestDirectoryInternalRelative);

        if (!Directory.Exists(rootFolder))
        {
            Directory.CreateDirectory(rootFolder);
        }

        if (_copyManifestExternal && !String.IsNullOrEmpty(_manifestDirectoryExport))
        {
            File.WriteAllText(GetCustomManifestPath(_manifestDirectoryExport), manifestAsJson);
            Process.Start(_manifestDirectoryExport);
        }
        else
        {
            File.WriteAllText(GetCustomManifestPath(rootFolder), manifestAsJson);
        }
    }
    /**
     * Build is called when Unity builds assets with AssetBundle Graph.
     */
    public override void Build(BuildTarget target,
                               Model.NodeData node,
                               IEnumerable <PerformGraph.AssetGroups> incoming,
                               IEnumerable <Model.ConnectionData> connectionsToOutput,
                               PerformGraph.Output outputFunc,
                               Action <Model.NodeData, string, float> progressFunc)
    {
        List <Dictionary <string, List <AssetReference> > > groups = new List <Dictionary <string, List <AssetReference> > >();

        foreach (var assetGroups in incoming)
        {
            groups.Add(assetGroups.assetGroups);
        }

        var jsonSerializer = new JsonSerializer(new JsonSerializerSettings {
            Formatting = Formatting.Indented
        }, Encoding.UTF8);

        var path = PrepareOutputDirectory(target, node, false, true);

        File.WriteAllText(path + _fileName[target] + ".json", jsonSerializer.SerializeString(groups));
    }