Exemple #1
0
 public AssetGroups(Model.ConnectionData c, Dictionary <string, List <AssetReference> > ag)
 {
     connection  = c;
     assetGroups = ag;
 }
Exemple #2
0
        public override void Prepare(BuildTarget target,
                                     Model.NodeData node,
                                     IEnumerable <PerformGraph.AssetGroups> incoming,
                                     IEnumerable <Model.ConnectionData> connectionsToOutput,
                                     PerformGraph.Output Output)
        {
            ValidateAssetGenerator(node, target, incoming,
                                   () => {
                throw new NodeException("AssetGenerator is not specified.", "Select generator from inspector.", node);
            },
                                   () => {
                throw new NodeException("Failed to create AssetGenerator from settings.", "Fix AssetGenerator settings from inspector", node);
            },
                                   (AssetReference badAsset) => {
                throw new NodeException($"Generator not create asset from source : Source: {badAsset.importFrom}",
                                        "Remove source asset from node input.", node);
            },
                                   (AssetReference badAsset) => {
                throw new NodeException($"Can not import incoming asset {badAsset.fileNameAndExtension}.",
                                        "Remove source asset from node input.", node);
            }
                                   );

            if (incoming == null)
            {
                return;
            }

            if (connectionsToOutput == null || Output == null)
            {
                return;
            }

            var allOutput = new Dictionary <string, Dictionary <string, List <AssetReference> > >();

            foreach (var outPoints in node.OutputPoints)
            {
                allOutput[outPoints.Id] = new Dictionary <string, List <AssetReference> >();
            }

            var defaultOutputCond = connectionsToOutput.Where(c => c.FromNodeConnectionPointId == m_defaultOutputPointId);

            Model.ConnectionData defaultOutput = null;
            if (defaultOutputCond.Any())
            {
                defaultOutput = defaultOutputCond.First();
            }

            foreach (var ag in incoming)
            {
                if (defaultOutput != null)
                {
                    Output(defaultOutput, ag.assetGroups);
                }
                foreach (var groupKey in ag.assetGroups.Keys)
                {
                    foreach (var a in ag.assetGroups[groupKey])
                    {
                        foreach (var entry in m_entries)
                        {
                            var assetOutputDir = PrepareOutputDirectory(target, node, a);
                            var generator      = entry.m_instance.Get <IAssetGenerator>(target);
                            UnityEngine.Assertions.Assert.IsNotNull(generator);

                            var newItem = FileUtility.PathCombine(assetOutputDir, GetGeneratorIdForSubPath(target, entry), a.fileName + generator.GetAssetExtension(a));
                            var output  = allOutput[entry.m_id];
                            if (!output.ContainsKey(groupKey))
                            {
                                output[groupKey] = new List <AssetReference>();
                            }
                            output[groupKey].Add(AssetReferenceDatabase.GetReferenceWithType(newItem, generator.GetAssetType(a)));
                        }
                    }
                }
            }

            foreach (var dst in connectionsToOutput)
            {
                if (allOutput.ContainsKey(dst.FromNodeConnectionPointId))
                {
                    Output(dst, allOutput[dst.FromNodeConnectionPointId]);
                }
            }
        }
 public void AssignAssetGroup(Model.ConnectionData connection, Dictionary <string, List <AssetReference> > groups)
 {
     m_connectionStreamMap[connection.Id] = groups;
 }