Beispiel #1
0
        public void Clear(bool executeGraphsWithError)
        {
            List <string> graphGuids = null;

            if (executeGraphsWithError)
            {
                graphGuids = m_events.Where(e => e.Kind == AssetProcessEvent.EventKind.Error).Select(e => e.GraphGuid).Distinct().ToList();
            }

            m_events.Clear();
            m_filteredEvents.Clear();
            m_errorEventCount         = 0;
            m_infoEventCount          = 0;
            m_filteredInfoEventCount  = 0;
            m_filteredErrorEventCount = 0;

            if (executeGraphsWithError)
            {
                var graphGuidWithoutHidden =
                    graphGuids.Select(AssetDatabase.GUIDToAssetPath)
                    .Where(string.IsNullOrEmpty)
                    .Where(path => path.Contains(Model.Settings.HIDE_GRAPH_PREFIX))
                    .ToList();

                AssetGraphUtility.ExecuteAllGraphs(graphGuidWithoutHidden, true);
            }
        }
Beispiel #2
0
        private void UpdateBuildMap()
        {
            UpdateGraphInfo();

            string path = AssetDatabase.GUIDToAssetPath(m_graphGuid);

            if (string.IsNullOrEmpty(path))
            {
                return;
            }

            AssetBundleBuildMap.GetBuildMap().Clear();
            AssetGraphUtility.ExecuteGraphSetup(path);
        }
Beispiel #3
0
        public void Clear(bool executeGraphsWithError)
        {
            List <string> graphGuids = null;

            if (executeGraphsWithError)
            {
                graphGuids = m_events.Where(e => e.Kind == AssetProcessEvent.EventKind.Error).Select(e => e.GraphGuid).Distinct().ToList();
            }

            m_events.Clear();
            m_filteredEvents.Clear();
            m_errorEventCount = 0;
            m_infoEventCount  = 0;

            if (executeGraphsWithError)
            {
                AssetGraphUtility.ExecuteAllGraphs(graphGuids, true);
            }
        }
Beispiel #4
0
        public void Build()
        {
            m_result.Clear();

            var currentCount = 0f;
            var totalCount   = (float)GetTotalNodeCount(m_currentCollection) * BatchBuildConfig.GetConfig().BuildTargets.Count;

            Model.NodeData lastNode = null;

            foreach (var t in BatchBuildConfig.GetConfig().BuildTargets)
            {
                Action <Model.NodeData, string, float> updateHandler = (node, message, progress) => {
                    if (lastNode != node)
                    {
                        // do not add count on first node visit to
                        // calcurate percantage correctly
                        if (lastNode != null)
                        {
                            ++currentCount;
                        }
                        lastNode = node;
                    }

                    var currentNodeProgress  = progress * (1.0f / totalCount);
                    var currentTotalProgress = (currentCount / totalCount) + currentNodeProgress;

                    var title = string.Format("{2} - Processing Asset Graphs[{0}/{1}]", currentCount, totalCount, BuildTargetUtility.TargetToHumaneString(t));
                    var info  = $"{node.Name}:{message}";

                    EditorUtility.DisplayProgressBar(title, "Processing " + info, currentTotalProgress);
                };

                var result = AssetGraphUtility.ExecuteGraphCollection(t, m_currentCollection, updateHandler);
                EditorUtility.ClearProgressBar();
                m_result.AddRange(result);

                m_lastBuildTimestamp = DateTime.UtcNow.ToFileTimeUtc();

                m_executeResultTree.ReloadAndSelectLast();
                m_parent.Repaint();
            }
        }
Beispiel #5
0
        public bool BuildAssetBundles(AssetBundleBrowser.AssetBundleDataSource.ABBuildInfo info)
        {
            AssetBundleBuildMap.GetBuildMap().Clear();

            UpdateGraphInfo();

            if (string.IsNullOrEmpty(m_graphGuid))
            {
                return(false);
            }

            string path = AssetDatabase.GUIDToAssetPath(m_graphGuid);

            if (string.IsNullOrEmpty(path))
            {
                return(false);
            }

            var graph = AssetDatabase.LoadAssetAtPath <Model.ConfigGraph>(path);

            Type infoType = info.GetType();

            var fieldInfo = infoType.GetField("buildTarget");

            if (fieldInfo != null)
            {
                BuildTarget target = (BuildTarget)fieldInfo.GetValue(info);
                var         result = AssetGraphUtility.ExecuteGraph(target, graph);
                if (result.IsAnyIssueFound)
                {
                    return(false);
                }
            }

            return(true);
        }
        private void NotifyAssetPostprocessorGraphs(AssetPostprocessorContext ctx)
        {
            var guids = AssetDatabase.FindAssets(Model.Settings.GRAPH_SEARCH_CONDITION);

            var executingGraphs = new List <Model.ConfigGraph> ();

            foreach (var guid in guids)
            {
                string path  = AssetDatabase.GUIDToAssetPath(guid);
                var    graph = AssetDatabase.LoadAssetAtPath <Model.ConfigGraph>(path);
                if (graph != null && graph.UseAsAssetPostprocessor)
                {
                    bool isAnyNodeAffected = false;
                    foreach (var n in graph.Nodes)
                    {
                        isAnyNodeAffected |= n.Operation.Object.OnAssetsReimported(n, null, EditorUserBuildSettings.activeBuildTarget, ctx, true);
                    }
                    if (isAnyNodeAffected)
                    {
                        executingGraphs.Add(graph);
                    }
                }
            }

            if (executingGraphs.Count > 0)
            {
                if (executingGraphs.Count > 1)
                {
                    executingGraphs.Sort((l, r) => l.ExecuteOrderPriority - r.ExecuteOrderPriority);
                }

                float          currentCount            = 0f;
                float          totalCount              = (float)executingGraphs.Sum(g => g.Nodes.Count);
                Model.NodeData lastNode                = null;
                float          graphStartTime          = Time.realtimeSinceStartup;
                bool           progressbarDisplayed    = false;
                float          progressBarShowDelaySec = 0.3f;

                Action <Model.NodeData, string, float> updateHandler = (node, message, progress) => {
                    if (lastNode != node)
                    {
                        // do not add count on first node visit to
                        // calcurate percantage correctly
                        if (lastNode != null)
                        {
                            ++currentCount;
                        }
                        lastNode = node;

                        if (!progressbarDisplayed)
                        {
                            if (Time.realtimeSinceStartup - graphStartTime > progressBarShowDelaySec)
                            {
                                progressbarDisplayed = true;
                            }
                        }
                    }

                    if (progressbarDisplayed)
                    {
                        var graphName = GetCurrentGraphController().TargetGraph.GetGraphName();

                        float currentNodeProgress  = progress * (1.0f / totalCount);
                        float currentTotalProgress = (currentCount / totalCount) + currentNodeProgress;

                        string title = string.Format("Building {2}[{0}/{1}]", currentCount, totalCount, graphName);
                        string info  = $"Processing {node.Name}:{message}";

                        EditorUtility.DisplayProgressBar(title, info, currentTotalProgress);
                    }
                };

                foreach (var g in executingGraphs)
                {
                    AssetGraphUtility.ExecuteGraph(g, false, updateHandler);
                }

                if (progressbarDisplayed)
                {
                    EditorUtility.ClearProgressBar();
                }

                AssetDatabase.Refresh();
            }
        }
Beispiel #7
0
        /**
         * Build from commandline - entrypoint.
         */
        public static void BuildFromCommandline()
        {
            try {
                var arguments = new List <string>(System.Environment.GetCommandLineArgs());

                Application.SetStackTraceLogType(LogType.Log, StackTraceLogType.None);
                Application.SetStackTraceLogType(LogType.Error, StackTraceLogType.None);
                Application.SetStackTraceLogType(LogType.Warning, StackTraceLogType.None);

                BuildTarget target = EditorUserBuildSettings.activeBuildTarget;

                int targetIndex = arguments.FindIndex(a => a == "-target");

                if (targetIndex >= 0)
                {
                    var targetStr = arguments[targetIndex + 1];
                    LogUtility.Logger.Log("Target specified:" + targetStr);

                    var newTarget = BuildTargetUtility.BuildTargetFromString(arguments[targetIndex + 1]);
                    if (!BuildTargetUtility.IsBuildTargetSupported(newTarget))
                    {
                        throw new AssetGraphException(newTarget + " is not supported to build with this Unity. Please install platform support with installer(s).");
                    }

                    if (newTarget != target)
                    {
                                                #if UNITY_5_6 || UNITY_5_6_OR_NEWER
                        EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetUtility.TargetToGroup(newTarget), newTarget);
                                                #else
                        EditorUserBuildSettings.SwitchActiveBuildTarget(newTarget);
                                                #endif
                        target = newTarget;
                    }
                }

                int graphIndex      = arguments.FindIndex(a => a == "-graph");
                int collectionIndex = arguments.FindIndex(a => a == "-collection");

                if (graphIndex >= 0 && collectionIndex >= 0)
                {
                    LogUtility.Logger.Log("-graph and -collection can not be used at once. Aborting...");
                    return;
                }

                Model.ConfigGraph graph = null;

                if (graphIndex >= 0)
                {
                    var graphPath = arguments[graphIndex + 1];
                    LogUtility.Logger.Log("Graph path:" + graphPath);

                    graph = AssetDatabase.LoadAssetAtPath <Model.ConfigGraph>(graphPath);

                    LogUtility.Logger.Log("AssetReference bundle building for:" + BuildTargetUtility.TargetToHumaneString(target));

                    if (graph == null)
                    {
                        LogUtility.Logger.Log("Graph data not found. To specify graph to execute, use -graph [path]. Aborting...");
                        return;
                    }

                    var result = AssetGraphUtility.ExecuteGraph(target, graph);

                    if (result.IsAnyIssueFound)
                    {
                        LogUtility.Logger.Log("Building asset bundles terminated because of following errors. Please fix issues by opening editor.");
                        foreach (var e in result.Issues)
                        {
                            LogUtility.Logger.LogError(LogUtility.kTag, e.Reason);
                        }
                    }
                }

                if (collectionIndex >= 0)
                {
                    var collectionName = arguments[collectionIndex + 1];
                    LogUtility.Logger.Log("Collection Name:" + collectionName);

                    LogUtility.Logger.Log("AssetReference bundle building for:" + BuildTargetUtility.TargetToHumaneString(target));

                    if (collectionName == null)
                    {
                        LogUtility.Logger.Log("Collection name not specified. To specify collection to execute, use -collection [name]. Aborting...");
                        return;
                    }
                    BatchBuildConfig.GraphCollection c = BatchBuildConfig.GetConfig().Find(collectionName);
                    if (c == null)
                    {
                        LogUtility.Logger.Log("Collection not found. Please open project and configure graph collection. Aborting...");
                        return;
                    }

                    var result = AssetGraphUtility.ExecuteGraphCollection(target, c);

                    foreach (var r in result)
                    {
                        if (r.IsAnyIssueFound)
                        {
                            foreach (var e in r.Issues)
                            {
                                LogUtility.Logger.LogError(LogUtility.kTag, r.Graph.name + ":" + e.Reason);
                            }
                        }
                    }
                }
            } catch (Exception e) {
                LogUtility.Logger.LogError(LogUtility.kTag, e);
                LogUtility.Logger.LogError(LogUtility.kTag, "Building asset bundles terminated due to unexpected error.");
            } finally {
                LogUtility.Logger.Log("End of build.");
            }
        }