/** * 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."); } }
private void DrawBuildDropdown(Rect region) { var popupRgn = new Rect(region.x + 20f, region.y, region.width - 120f, region.height); var buttonRgn = new Rect(popupRgn.xMax + 8f, popupRgn.y, 80f, popupRgn.height); using (new EditorGUI.DisabledGroupScope(BatchBuildConfig.GetConfig().GraphCollections.Count == 0)) { var newIndex = EditorGUI.Popup(popupRgn, "Graph Collection", m_selectedCollectionIndex, m_collectionNames); if (newIndex != m_selectedCollectionIndex) { m_selectedCollectionIndex = newIndex; m_currentCollection = BatchBuildConfig.GetConfig().GraphCollections [m_selectedCollectionIndex]; m_selectedCollectionGuid = m_currentCollection.Guid; } using (new EditorGUI.DisabledGroupScope(m_currentCollection == null || BatchBuildConfig.GetConfig().BuildTargets.Count == 0)) { if (GUI.Button(buttonRgn, "Execute")) { Build(); } } } }
public void OnGUI(Rect pos) { var dropdownUIBound = new Rect(0f, 0f, pos.width, 16f); var labelUIBound = new Rect(4f, dropdownUIBound.yMax, 80f, 24f); var listviewUIBound = new Rect(4f, labelUIBound.yMax, dropdownUIBound.width - 8f, pos.height - dropdownUIBound.yMax); DrawBuildDropdown(dropdownUIBound); var labelStyle = new GUIStyle(EditorStyles.label); labelStyle.alignment = TextAnchor.LowerLeft; GUI.Label(labelUIBound, "Build Targets", labelStyle); using (new GUI.GroupScope(listviewUIBound)) { var groupUIBound = new Rect(0f, 0f, listviewUIBound.width, listviewUIBound.height); HandleVerticalResize(groupUIBound, ref m_verticalSplitterRect, ref m_verticalSplitterPercent, ref m_resizingVerticalSplitter, ref kSritRange); var boundTop = new Rect( 4f, 0f, groupUIBound.width - 8f, m_verticalSplitterRect.y); var bottomLabelUIBound = new Rect(4f, m_verticalSplitterRect.yMax, 80f, 24f); var boundBottom = new Rect( boundTop.x, bottomLabelUIBound.yMax, boundTop.width, groupUIBound.height - m_verticalSplitterRect.yMax); var bottomUIBound = new Rect(0f, 0f, boundBottom.width, boundBottom.height); GUI.Label(bottomLabelUIBound, "Build Results", labelStyle); m_buildTargetTree.OnGUI(boundTop); if (BatchBuildConfig.GetConfig().BuildTargets.Count == 0) { var style = GUI.skin.label; style.alignment = TextAnchor.MiddleCenter; style.wordWrap = true; GUI.Label(new Rect(boundTop.x + 12f, boundTop.y, boundTop.width - 24f, boundTop.height), new GUIContent("Right click here and add targets to build."), style); } using (new GUI.GroupScope(boundBottom, EditorStyles.helpBox)) { HandleVerticalResize(bottomUIBound, ref m_msgVerticalSplitterRect, ref m_msgVerticalSplitterPercent, ref m_msgResizingVerticalSplitter, ref kMsgSpritRange); var execResultBound = new Rect( 0f, 0f, bottomUIBound.width, m_msgVerticalSplitterRect.y); var msgBound = new Rect( execResultBound.x, m_msgVerticalSplitterRect.yMax, execResultBound.width, bottomUIBound.height - m_msgVerticalSplitterRect.yMax - 52f); m_executeResultTree.OnGUI(execResultBound); DrawSelectedExecuteResultMessage(msgBound); } if (m_resizingVerticalSplitter || m_msgResizingVerticalSplitter) { m_parent.Repaint(); } } }