예제 #1
0
        /// <summary>
        /// Executes the graph.
        /// </summary>
        /// <returns>The graph.</returns>
        /// <param name="target">Target.</param>
        /// <param name="graph">Graph.</param>
        public static ExecuteGraphResult ExecuteGraph(BuildTarget target, Model.ConfigGraph graph, bool clearRecord = false, Action <Model.NodeData, string, float> updateHandler = null)
        {
            if (clearRecord)
            {
                AssetProcessEventRecord.GetRecord().Clear(false);
            }

            string assetPath = AssetDatabase.GetAssetPath(graph);

            LogUtility.Logger.LogFormat(LogType.Log, "Executing graph:{0}", assetPath);

            AssetGraphController c = new AssetGraphController(graph);

            // perform setup. Fails if any exception raises.
            c.Perform(target, false, true, true, null);

            // if there is error reported, then run
            if (c.IsAnyIssueFound)
            {
                return(new ExecuteGraphResult(target, graph, c.Issues));
            }

            Model.NodeData lastNodeData = null;
            float          lastProgress = 0.0f;

            Action <Model.NodeData, string, float> defaultUpdateHandler = (Model.NodeData node, string message, float progress) => {
                if (node != null && lastNodeData != node)
                {
                    lastNodeData = node;
                    lastProgress = progress;

                    LogUtility.Logger.LogFormat(LogType.Log, "Processing {0}", node.Name);
                }
                if (progress > lastProgress)
                {
                    if (progress <= 1.0f)
                    {
                        LogUtility.Logger.LogFormat(LogType.Log, "{0} Complete.", node.Name);
                    }
                    else if ((progress - lastProgress) > 0.2f)
                    {
                        LogUtility.Logger.LogFormat(LogType.Log, "{0}: {1} % : {2}", node.Name, (int)progress * 100f, message);
                    }
                    lastProgress = progress;
                }
            };

            if (updateHandler == null)
            {
                updateHandler = defaultUpdateHandler;
            }

            // run datas.
            c.Perform(target, true, true, true, updateHandler);

            AssetDatabase.Refresh();

            return(new ExecuteGraphResult(target, graph, c.Issues));
        }
예제 #2
0
        /// <summary>
        /// Execute Graph in Setup mode, and do not do Build.
        /// </summary>
        /// <returns>The graph.</returns>
        /// <param name="target">Target.</param>
        /// <param name="graph">Graph.</param>
        public static ExecuteGraphResult ExecuteGraphSetup(BuildTarget target, Model.ConfigGraph graph)
        {
            AssetGraphController c = new AssetGraphController(graph);

            c.Perform(target, false, true, true, null);
            return(new ExecuteGraphResult(target, graph, c.Issues));
        }