Exemple #1
0
        private void CellGUI(Rect cellRect, TreeViewItem item, int column, ref RowGUIArgs args)
        {
            ExecuteResultTreeItem resultItem    = item as ExecuteResultTreeItem;
            NodeExceptionItem     exceptionItem = item as NodeExceptionItem;

            ExecuteGraphResult r = null;
            NodeException      e = null;

            if (resultItem != null)
            {
                r = resultItem.Result;
            }
            else
            {
                r = exceptionItem.Result;
                e = exceptionItem.Exception;
            }

            switch (column)
            {
            case 0://Collapse/Expand
            {
                DefaultGUI.Label(cellRect, string.Empty, args.selected, args.focused);
            }
            break;

            case 1://Status
            {
                var rect = cellRect;
                if (e != null)
                {
                    rect.x += 8f;
                }
                DefaultGUI.Label(rect, (r.IsAnyIssueFound) ? "Fail" : "Success", args.selected, args.focused);
            }
            break;

            case 2://Graph
            {
                var graphName = Path.GetFileNameWithoutExtension(r.GraphAssetPath);
                DefaultGUI.Label(cellRect, graphName, args.selected, args.focused);
            }
            break;

            case 3://Platform
                DefaultGUI.Label(cellRect, BuildTargetUtility.TargetToHumaneString(r.Target), args.selected, args.focused);
                break;

            case 4://Description
                if (e != null)
                {
                    DefaultGUI.Label(cellRect, e.Reason, args.selected, args.focused);
                }
                else
                {
                    DefaultGUI.Label(cellRect, string.Empty, args.selected, args.focused);
                }
                break;
            }
        }
Exemple #2
0
        private void DrawSelectedExecuteResultMessage(Rect region)
        {
            string msg = null;

            // no item selected
            if (m_selectedResult == null)
            {
                msg = string.Empty;
            }
            // build result
            else if (m_selectedException == null)
            {
                var graphName = Path.GetFileNameWithoutExtension(m_selectedResult.GraphAssetPath);
                msg = string.Format("Build {2}.\n\nGraph:{0}\nPlatform:{1}",
                                    graphName,
                                    BuildTargetUtility.TargetToHumaneString(m_selectedResult.Target),
                                    m_selectedResult.IsAnyIssueFound ? "Failed" : "Successful"
                                    );
            }
            // build result with exception
            else
            {
                var graphName = Path.GetFileNameWithoutExtension(m_selectedResult.GraphAssetPath);
                msg = string.Format("{0}\n\nHow to fix:\n{1}\n\nWhere:'{2}' in {3}\nPlatform:{4}",
                                    m_selectedException.Reason, m_selectedException.HowToFix, m_selectedException.Node.Name,
                                    graphName,
                                    BuildTargetUtility.TargetToHumaneString(m_selectedResult.Target));
            }

            var msgStyle = GUI.skin.label;

            msgStyle.alignment = TextAnchor.UpperLeft;
            msgStyle.wordWrap  = true;

            var content = new GUIContent(msg);
            var height  = msgStyle.CalcHeight(content, region.width - 16f);

            var msgRect = new Rect(0f, 0f, region.width - 16f, height);

            m_msgScrollPos = GUI.BeginScrollView(region, m_msgScrollPos, msgRect);

            GUI.Label(msgRect, content);

            GUI.EndScrollView();
        }
        protected override void ContextClicked()
        {
            if (m_ctxMenuClickOnItem)
            {
                m_ctxMenuClickOnItem = false;
                return;
            }

            GenericMenu menu = new GenericMenu();

            var currentTargets = BatchBuildConfig.GetConfig().BuildTargets;

            foreach (var t in NodeGUIUtility.SupportedBuildTargets)
            {
                if (!currentTargets.Contains(t))
                {
                    menu.AddItem(new GUIContent($"Add {BuildTargetUtility.TargetToHumaneString(t)}"), false, () => { MenuAction_AddTarget(t); });
                }
            }

            menu.ShowAsContext();
        }
            public void SetupSupportedBuildTargets()
            {
                if (supportedBuildTargets == null)
                {
                    supportedBuildTargets      = new List <BuildTarget>();
                    supportedBuildTargetGroups = new List <BuildTargetGroup>();

                    try {
                        foreach (BuildTarget target in Enum.GetValues(typeof(BuildTarget)))
                        {
                            if (BuildTargetUtility.IsBuildTargetSupported(target))
                            {
                                if (!supportedBuildTargets.Contains(target))
                                {
                                    supportedBuildTargets.Add(target);
                                }
                                BuildTargetGroup g = BuildTargetUtility.TargetToGroup(target);
                                if (g == BuildTargetGroup.Unknown)
                                {
                                    // skip unknown platform
                                    continue;
                                }
                                if (!supportedBuildTargetGroups.Contains(g))
                                {
                                    supportedBuildTargetGroups.Add(g);
                                }
                            }
                        }

                        supportedBuildTargetNames = new string[supportedBuildTargets.Count];
                        for (int i = 0; i < supportedBuildTargets.Count; ++i)
                        {
                            supportedBuildTargetNames[i] = BuildTargetUtility.TargetToHumaneString(supportedBuildTargets[i]);
                        }
                    } catch (Exception e) {
                        LogUtility.Logger.LogError(LogUtility.kTag, e);
                    }
                }
            }
 public BuildTargetTreeItem(BuildTarget t) : base((int)t, 0, string.Empty)
 {
     m_group     = BuildTargetUtility.TargetToGroup(t);
     m_target    = t;
     displayName = BuildTargetUtility.TargetToHumaneString(m_target);
 }
Exemple #6
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();
            }
        }
Exemple #7
0
 public ExecuteResultTreeItem(ExecuteGraphResult r) : base(s_id++, 0, string.Empty)
 {
     m_result    = r;
     displayName = string.Format("{0}({1}):{2}", Path.GetFileNameWithoutExtension(r.GraphAssetPath), BuildTargetUtility.TargetToHumaneString(r.Target), (r.IsAnyIssueFound)?"Failed" : "Good");
 }
Exemple #8
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.");
            }
        }