Esempio n. 1
0
        public void BuildGraphFromSaveData(Model.ConfigGraph graph, BuildTarget target, PerformGraph old)
        {
            m_target = target;

            ValidateLoopConnection(graph);

            m_nodes.Clear();
            m_streams.Clear();

            foreach (var n in graph.Nodes)
            {
                SetupNode(n);
            }

            foreach (var c in graph.Connections)
            {
                SetupStream(c);
            }

            /*
             * All nodes needs revisit when target has changed.
             * Do modification check only when targeting the same build target
             * from last one.
             */
            if (m_target == old.m_target)
            {
                CompareAndMarkModified(old);
            }
        }
Esempio n. 2
0
        private void CompareAndMarkModified(PerformGraph old)
        {
            foreach (var n in m_nodes)
            {
                n.dirty = false;

                if (old == null)
                {
                    n.dirty = true;
                    LogUtility.Logger.Log(n.data.Name + " mark modified.(old=null)");
                }
                else
                {
                    Node oldNode = old.m_nodes.Find(x => x.data.Id == n.data.Id);
                    // this is new node
                    if (oldNode == null)
                    {
                        LogUtility.Logger.Log(n.data.Name + " mark modified.(oldnode null)");
                        n.dirty = true;
                    }
                    else if (n.data.NeedsRevisit)
                    {
                        n.dirty = true;
                    }
                    else if (!n.originalData.CompareIgnoreGUIChanges(oldNode.originalData))
                    {
                        n.dirty = true;
                    }
                }
            }

            foreach (var s in m_streams)
            {
                if (old == null)
                {
                }
                else
                {
                    AssetStream oldStream = old.m_streams.Find(x => s.connection.Id == x.connection.Id);
                    if (oldStream == null)
                    {
                        s.nodeFrom.dirty = true;
                        s.nodeTo.dirty   = true;
                    }
                }
            }

            var deletedStreams = old.m_streams.Except(m_streams);

            if (deletedStreams.Any())
            {
                foreach (var deleted in deletedStreams)
                {
                    m_streamManager.RemoveAssetGroup(deleted.connection);

                    var receiver = m_nodes.Find(n => n.data.Id == deleted.nodeTo.data.Id);
                    if (receiver != null)
                    {
                        LogUtility.Logger.LogFormat(LogType.Log, "{0} input is removed. making it dirty...", receiver.data.Name);
                        receiver.dirty = true;
                    }
                }
            }
        }
Esempio n. 3
0
        /**
         * Execute Run operations using current graph
         */
        public bool Perform(
            BuildTarget target,
            bool isBuild,
            bool logIssues,
            bool forceVisitAll,
            Action <Model.NodeData, string, float> updateHandler)
        {
            if (m_targetGraph == null)
            {
                LogUtility.Logger.LogError(LogUtility.kTag, "Attempted to execute invalid graph (null)");
                return(false);
            }

            AssetGraphPostprocessor.Postprocessor.PushController(this);

            LogUtility.Logger.Log(LogType.Log, (isBuild) ? "---Build BEGIN---" : "---Setup BEGIN---");
            m_isBuilding = true;

            if (isBuild)
            {
                AssetBundleBuildReport.ClearReports();
            }

            foreach (var e in m_nodeExceptions)
            {
                var errorNode = m_targetGraph.Nodes.Find(n => n.Id == e.NodeId);
                // errorNode may not be found if user delete it on graph
                if (errorNode != null)
                {
                    LogUtility.Logger.LogFormat(LogType.Log, "[Perform] {0} is marked to revisit due to last error", errorNode.Name);
                    errorNode.NeedsRevisit = true;
                }
            }

            m_nodeExceptions.Clear();
            m_lastTarget = target;

            try {
                PerformGraph oldGraph = m_performGraph[gIndex];
                gIndex = (gIndex + 1) % 2;
                PerformGraph newGraph = m_performGraph[gIndex];
                newGraph.BuildGraphFromSaveData(m_targetGraph, target, oldGraph);

                PerformGraph.Perform performFunc =
                    (Model.NodeData data,
                     IEnumerable <PerformGraph.AssetGroups> incoming,
                     IEnumerable <Model.ConnectionData> connectionsToOutput,
                     PerformGraph.Output outputFunc) =>
                {
                    DoNodeOperation(target, data, incoming, connectionsToOutput, outputFunc, isBuild, updateHandler);
                };

                newGraph.VisitAll(performFunc, forceVisitAll);

                if (isBuild && m_nodeExceptions.Count == 0)
                {
                    Postprocess();
                }
            }
            catch (NodeException e) {
                m_nodeExceptions.Add(e);
            }
            // Minimize impact of errors happened during node operation
            catch (Exception e) {
                LogUtility.Logger.LogException(e);
            }

            m_isBuilding = false;
            LogUtility.Logger.Log(LogType.Log, (isBuild) ? "---Build END---" : "---Setup END---");

            if (logIssues)
            {
                LogIssues();
            }

            AssetGraphPostprocessor.Postprocessor.PopController();

            return(true);
        }