private DragAndDropVisualMode HandleDragDropBetween(DragAndDropData data) { DragAndDropVisualMode visualMode = DragAndDropVisualMode.Move; var parent = (data.args.parentItem as GraphCollectionTreeItem); if (parent != null) { if (data.args.performDrop) { var collection = BatchBuildConfig.GetConfig().GraphCollections; collection.Remove(data.draggedNode.Collection); if (data.args.insertAtIndex < collection.Count) { collection.Insert(data.args.insertAtIndex, data.draggedNode.Collection); } else { collection.Add(data.draggedNode.Collection); } BatchBuildConfig.SetConfigDirty(); ReloadAndSelect(); } } return(visualMode); }
public void OnGUI(Rect pos) { m_Position = pos; var toolbarBound = new Rect(0f, 0f, m_Position.width, _assetGraphGuiConfig.TOOLBAR_HEIGHT); DrawToolBar(toolbarBound); if ((BatchBuildConfig.GetConfig().GraphCollections.Count == 0)) { var bound = new Rect( toolbarBound.x + 4f, toolbarBound.yMax, m_Position.width - 8f, m_Position.height - toolbarBound.height - 4f); var style = GUI.skin.label; style.alignment = TextAnchor.MiddleCenter; style.wordWrap = true; m_collectionTree.OnGUI(bound); GUI.Label(new Rect(bound.x + 12f, bound.y, bound.width - 24f, bound.height), new GUIContent("Drag graph assets here or press Add button to begin creating graph collections."), style); } else { HandleHorizontalResize(); //Left half var leftBound = new Rect( toolbarBound.x + 4f, toolbarBound.yMax, m_HorizontalSplitterRect.x, m_Position.height - toolbarBound.height - 4f); m_collectionTree.OnGUI(leftBound); //Right half. float panelLeft = m_HorizontalSplitterRect.x + k_SplitterWidth; float panelWidth = m_Position.width - m_HorizontalSplitterRect.x - k_SplitterWidth * 2; var rightBound = new Rect( panelLeft, toolbarBound.yMax, panelWidth, m_Position.height - toolbarBound.height - 4f); m_detailTree.OnGUI(rightBound); if (m_ResizingHorizontalSplitter) { m_Parent.Repaint(); } } }
private void MenuAction_RemoveCollection(object context) { var item = context as BuildTargetTreeItem; BatchBuildConfig.GetConfig().BuildTargets.Remove(item.Target); BatchBuildConfig.SetConfigDirty(); Reload(); }
private void MenuAction_RemoveCollection(object context) { var item = context as GraphCollectionTreeItem; BatchBuildConfig.GetConfig().GraphCollections.Remove(item.Collection); m_controller.UpdateSelectedGraphCollection(null); BatchBuildConfig.SetConfigDirty(); ReloadAndSelect(); }
public bool TryRename(string newName) { var collection = BatchBuildConfig.GetConfig().GraphCollections; if (collection.Find(c => c.Name.ToLower() == newName.ToLower()) != null) { return(false); } m_name = newName; return(true); }
protected override TreeViewItem BuildRoot() { var root = new BuildTargetTreeItem(); foreach (var t in BatchBuildConfig.GetConfig().BuildTargets) { root.AddChild(new BuildTargetTreeItem(t)); } return(root); }
private void MenuAction_AddTarget(BuildTarget t) { var targets = BatchBuildConfig.GetConfig().BuildTargets; if (!targets.Contains(t)) { targets.Add(t); } BatchBuildConfig.SetConfigDirty(); Reload(); }
protected override TreeViewItem BuildRoot() { var root = new GraphCollectionTreeItem(); var collections = BatchBuildConfig.GetConfig().GraphCollections; foreach (var c in collections) { root.AddChild(new GraphCollectionTreeItem(c)); } return(root); }
/// <summary> /// Executes the graph collection. /// </summary> /// <returns>The graph collection.</returns> /// <param name="t">T.</param> /// <param name="collectionName">Collection name.</param> public static List <ExecuteGraphResult> ExecuteGraphCollection(BuildTarget t, string collectionName) { var c = BatchBuildConfig.GetConfig().Find(collectionName); if (c == null) { throw new AssetGraphException( $"Failed to build with graph collection. Graph collection '{collectionName}' not found. " ); } return(ExecuteGraphCollection(t, c)); }
public void OnFocus() { BatchBuildConfig.GetConfig().Validate(); switch (m_mode) { case Mode.Edit: m_manageTab.Refresh(); break; case Mode.Build: m_executeTab.Refresh(); break; } }
static public GraphCollection CreateNewGraphCollection(string suggestedName) { string nameCandidate = suggestedName; var collection = BatchBuildConfig.GetConfig().GraphCollections; int i = 0; while (true) { if (collection.Find(c => c.Name.ToLower() == nameCandidate.ToLower()) == null) { var newCollection = new GraphCollection(nameCandidate); collection.Add(newCollection); BatchBuildConfig.SetConfigDirty(); return(newCollection); } nameCandidate = string.Format("{0} {1}", suggestedName, ++i); } }
public void Refresh() { if (m_buildTargetTree != null) { m_buildTargetTree.Reload(); m_executeResultTree.ReloadIfNeeded(); var collection = BatchBuildConfig.GetConfig().GraphCollections; m_collectionNames = collection.Select(c => c.Name).ToArray(); m_selectedCollectionIndex = collection.FindIndex(c => c.Guid == m_selectedCollectionGuid); if (m_selectedCollectionIndex >= 0) { m_currentCollection = collection [m_selectedCollectionIndex]; } else { m_currentCollection = null; } } }
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(); } }
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(); } } } }
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(); }
private DragAndDropVisualMode HandleDragDropBetween(DragAndDropData data) { DragAndDropVisualMode visualMode = DragAndDropVisualMode.Rejected; var parent = (data.args.parentItem as BuildTargetTreeItem); if (parent != null && data.DraggedNode) { visualMode = DragAndDropVisualMode.Move; if (data.args.performDrop) { var targets = BatchBuildConfig.GetConfig().BuildTargets; var movingTargets = data.draggedNodes.Select(n => n.Target).ToList(); foreach (var t in movingTargets) { targets.Remove(t); } if (data.args.insertAtIndex < targets.Count) { targets.InsertRange(data.args.insertAtIndex, movingTargets); } else { targets.AddRange(movingTargets); } BatchBuildConfig.SetConfigDirty(); Reload(); } } return(visualMode); }
/** * 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."); } }
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(); } } }