示例#1
0
        public void BuildGraphFromSaveData(BuildTarget target, PerformGraph old)
        {
            var saveData = SaveData.Data;

            m_target = target;

            ValidateLoopConnection(saveData);

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

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

            foreach (var c in saveData.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);
            }
        }
        /**
         * Execute Run operations using current graph
         */
        public void Perform(
            BuildTarget target,
            bool isRun,
            bool forceVisitAll,
            Action <NodeData, string, float> updateHandler)
        {
            LogUtility.Logger.Log(LogType.Log, (isRun) ? "---Build BEGIN---" : "---Setup BEGIN---");
            m_isBuilding = true;

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

            var saveData = SaveData.Data;

            foreach (var e in m_nodeExceptions)
            {
                var errorNode = saveData.Nodes.Find(n => n.Id == e.Id);
                // 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;

            PerformGraph oldGraph = m_performGraph[gIndex];

            gIndex = (gIndex + 1) % 2;
            PerformGraph newGraph = m_performGraph[gIndex];

            newGraph.BuildGraphFromSaveData(target, oldGraph);

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

            newGraph.VisitAll(performFunc, forceVisitAll);

            if (isRun && m_nodeExceptions.Count == 0)
            {
                Postprocess();
            }

            m_isBuilding = false;
            LogUtility.Logger.Log(LogType.Log, (isRun) ? "---Build END---" : "---Setup END---");
        }
示例#3
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;
                    }
                }
            }
        }