From 961998c573beacd9b7b8e7883e6d687851aec41a Mon Sep 17 00:00:00 2001 From: BocuD Date: Tue, 6 Sep 2022 00:51:58 +0200 Subject: [PATCH] Improve publishing UI --- .../BuildHelper/Editor/BuildHelperWindow.cs | 252 +++++++++--------- .../Editor/EditorCameraGUIHelper.cs | 2 + 2 files changed, 131 insertions(+), 123 deletions(-) diff --git a/Packages/com.bocud.vrbuildhelper/BuildHelper/Editor/BuildHelperWindow.cs b/Packages/com.bocud.vrbuildhelper/BuildHelper/Editor/BuildHelperWindow.cs index c208ff9..724de7b 100644 --- a/Packages/com.bocud.vrbuildhelper/BuildHelper/Editor/BuildHelperWindow.cs +++ b/Packages/com.bocud.vrbuildhelper/BuildHelper/Editor/BuildHelperWindow.cs @@ -1990,154 +1990,177 @@ private void DrawPublishingOptions() GUILayout.FlexibleSpace(); EditorGUILayout.LabelField( $"{(APIUser.IsLoggedIn ? "Currently logged in as " + APIUser.CurrentUser.displayName : "")}", - styleRichTextLabel); - EditorGUILayout.EndHorizontal(); + styleRichTextLabel, GUILayout.ExpandWidth(false)); + + bool publishBlocked = !CheckAccount(buildHelperData.CurrentBranch); - if (!CheckAccount(buildHelperData.CurrentBranch, false)) + if (!publishBlocked) { - EditorGUILayout.HelpBox("The currently logged in user doesn't have permission to publish to this blueprint ID.", MessageType.Error); + if (GUILayout.Button(" Switch ", GUILayout.ExpandWidth(false))) + { + VRCSettings.ActiveWindowPanel = 0; + GetWindow(); + } } - - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.LabelField("Publish to VRChat"); - bool lastBuildBlocked = !CheckLastBuiltBranch(); - string lastBuildBlockedTooltip = - $"Your last build for the current platform couldn't be found, its hash doesn't match the last {CurrentPlatform()} build for this branch, or was built for a different blueprint ID."; + EditorGUILayout.EndHorizontal(); - using (new EditorGUI.DisabledScope(lastBuildBlocked)) + if (publishBlocked) { - lastBuildButton.tooltip = lastBuildBlocked - ? lastBuildBlockedTooltip - : "Equivalent to (Last build) Build & Publish in the VRChat SDK"; + EditorGUILayout.HelpBox("The currently logged in user doesn't have permission to publish to this blueprint ID.", MessageType.Error); - if (GUILayout.Button(lastBuildButton, buttonStyle)) + if (GUILayout.Button("Open VRChat SDK Control Panel to switch accounts")) { - BuildHelperData.RunLastBuildChecks(); - - if (CheckLastBuiltBranch()) - { - Branch targetBranch = buildHelperData.CurrentBranch; - - bool canPublish = true; - if (!targetBranch.remoteExists && !targetBranch.HasVRCDataChanges() && - BuildHelperEditorPrefs.UseAsyncPublish) - { - canPublish = EditorUtility.DisplayDialog("Build Helper", - $"You are about to publish a new world, but you haven't edited any world details. The async publisher doesn't enter playmode to let you edit world details, so your world will be uploaded as '{targetBranch.editedName}'. Do you want to continue?", - "Continue", "Cancel"); - } - - if (canPublish && CheckAccount(targetBranch)) - { - if (BuildHelperEditorPrefs.UseAsyncPublish) - { - Branch b = buildHelperData.CurrentBranch; - BuildHelperBuilder.PublishWorldAsync(b.buildData.CurrentPlatformBuildData().buildPath, - "", b.ToWorldInfo(), info => - { - Task verify = - buildHelperBehaviour.OnSuccesfulPublish(buildHelperData.CurrentBranch, - info.blueprintID, - DateTime.Now); - }); - } - else BuildHelperBuilder.PublishLastBuild(); - } - } - else - { - EditorUtility.DisplayDialog("BuildHelper", "Couldn't find the last build for this branch. Try building again.", "OK"); - } + VRCSettings.ActiveWindowPanel = 0; + GetWindow(); } } - newBuildButton.tooltip = "Equivalent to Build & Publish in the VRChat SDK"; - - if (GUILayout.Button(newBuildButton, buttonStyle)) + using (new EditorGUI.DisabledScope(publishBlocked)) { - Branch targetBranch = buildHelperData.CurrentBranch; + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.LabelField("Publish to VRChat"); - bool canPublish = true; - if (!targetBranch.remoteExists && !targetBranch.HasVRCDataChanges() && - BuildHelperEditorPrefs.UseAsyncPublish) - { - canPublish = EditorUtility.DisplayDialog("Build Helper", - $"You are about to publish a new world, but you haven't edited any world details. The async publisher doesn't enter playmode to let you edit world details, so your world will be uploaded as '{targetBranch.editedName}'. Do you want to continue?", - "Continue", "Cancel"); - } + bool lastBuildBlocked = !CheckLastBuiltBranch(); + string lastBuildBlockedTooltip = + $"Your last build for the current platform couldn't be found, its hash doesn't match the last {CurrentPlatform()} build for this branch, or was built for a different blueprint ID."; - if (canPublish && CheckAccount(targetBranch)) + using (new EditorGUI.DisabledScope(lastBuildBlocked)) { - if (BuildHelperEditorPrefs.UseAsyncPublish) + lastBuildButton.tooltip = lastBuildBlocked + ? lastBuildBlockedTooltip + : "Equivalent to (Last build) Build & Publish in the VRChat SDK"; + + if (GUILayout.Button(lastBuildButton, buttonStyle)) { - BuildHelperBuilder.PublishNewBuildAsync(buildHelperData.CurrentBranch.ToWorldInfo(), info => - { - Task verify = buildHelperBehaviour.OnSuccesfulPublish(buildHelperData.CurrentBranch, - info.blueprintID, DateTime.Now); - }); - } - else BuildHelperBuilder.PublishNewBuild(); - } + BuildHelperData.RunLastBuildChecks(); - return; - } + if (CheckLastBuiltBranch()) + { + Branch targetBranch = buildHelperData.CurrentBranch; - EditorGUILayout.EndHorizontal(); + bool canPublish = true; + if (!targetBranch.remoteExists && !targetBranch.HasVRCDataChanges() && + BuildHelperEditorPrefs.UseAsyncPublish) + { + canPublish = EditorUtility.DisplayDialog("Build Helper", + $"You are about to publish a new world, but you haven't edited any world details. The async publisher doesn't enter playmode to let you edit world details, so your world will be uploaded as '{targetBranch.editedName}'. Do you want to continue?", + "Continue", "Cancel"); + } - EditorGUILayout.BeginHorizontal(); - EditorGUILayout.LabelField("Autonomous Builder"); + if (canPublish) + { + if (BuildHelperEditorPrefs.UseAsyncPublish) + { + Branch b = buildHelperData.CurrentBranch; + BuildHelperBuilder.PublishWorldAsync( + b.buildData.CurrentPlatformBuildData().buildPath, + "", b.ToWorldInfo(), info => + { + Task verify = + buildHelperBehaviour.OnSuccesfulPublish(buildHelperData.CurrentBranch, + info.blueprintID, + DateTime.Now); + }); + } + else BuildHelperBuilder.PublishLastBuild(); + } + } + else + { + EditorUtility.DisplayDialog("BuildHelper", + "Couldn't find the last build for this branch. Try building again.", "OK"); + } + } + } - using (new EditorGUI.DisabledScope(!BuildHelperEditorPrefs.UseAsyncPublish)) - { - GUIContent autonomousBuilderButtonSingle = new GUIContent("Current platform", - BuildHelperEditorPrefs.UseAsyncPublish - ? "Publish your world autonomously" - : "To use the autonomous builder, please enable Async Publishing in settings"); + newBuildButton.tooltip = "Equivalent to Build & Publish in the VRChat SDK"; - if (GUILayout.Button(currentPlatformPublish, buttonStyle)) + if (GUILayout.Button(newBuildButton, buttonStyle)) { Branch targetBranch = buildHelperData.CurrentBranch; bool canPublish = true; - if (!targetBranch.remoteExists && !targetBranch.HasVRCDataChanges()) + if (!targetBranch.remoteExists && !targetBranch.HasVRCDataChanges() && + BuildHelperEditorPrefs.UseAsyncPublish) { canPublish = EditorUtility.DisplayDialog("Build Helper", - $"You are about to publish a new world using the autonomous builder, but you haven't edited any world details. The autonomous builder doesn't enter playmode to let you edit world details, so your world will be uploaded as '{targetBranch.editedName}'. Do you want to continue?", + $"You are about to publish a new world, but you haven't edited any world details. The async publisher doesn't enter playmode to let you edit world details, so your world will be uploaded as '{targetBranch.editedName}'. Do you want to continue?", "Continue", "Cancel"); } - if (canPublish && CheckAccount(targetBranch)) + if (canPublish) { - InitAutonomousBuild(true); + if (BuildHelperEditorPrefs.UseAsyncPublish) + { + BuildHelperBuilder.PublishNewBuildAsync(buildHelperData.CurrentBranch.ToWorldInfo(), info => + { + Task verify = buildHelperBehaviour.OnSuccesfulPublish(buildHelperData.CurrentBranch, + info.blueprintID, DateTime.Now); + }); + } + else BuildHelperBuilder.PublishNewBuild(); } + + return; } - GUIContent autonomousBuilderButton = new GUIContent("All platforms", - BuildHelperEditorPrefs.UseAsyncPublish - ? "Publish your world for both platforms simultaneously" - : "To use the autonomous builder, please enable Async Publishing in settings"); + EditorGUILayout.EndHorizontal(); + + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.LabelField("Autonomous Builder"); - if (GUILayout.Button(crossPlatformPublish, buttonStyle)) + using (new EditorGUI.DisabledScope(!BuildHelperEditorPrefs.UseAsyncPublish)) { - Branch targetBranch = buildHelperData.CurrentBranch; + GUIContent autonomousBuilderButtonSingle = new GUIContent("Current platform", + BuildHelperEditorPrefs.UseAsyncPublish + ? "Publish your world autonomously" + : "To use the autonomous builder, please enable Async Publishing in settings"); - bool canPublish = true; - if (!targetBranch.remoteExists && !targetBranch.HasVRCDataChanges()) + if (GUILayout.Button(currentPlatformPublish, buttonStyle)) { - canPublish = EditorUtility.DisplayDialog("Build Helper", - $"You are about to publish a new world using the autonomous builder, but you haven't edited any world details. The autonomous builder doesn't enter playmode to let you edit world details, so your world will be uploaded as '{targetBranch.editedName}'. Do you want to continue?", - "Continue", "Cancel"); + Branch targetBranch = buildHelperData.CurrentBranch; + + bool canPublish = true; + if (!targetBranch.remoteExists && !targetBranch.HasVRCDataChanges()) + { + canPublish = EditorUtility.DisplayDialog("Build Helper", + $"You are about to publish a new world using the autonomous builder, but you haven't edited any world details. The autonomous builder doesn't enter playmode to let you edit world details, so your world will be uploaded as '{targetBranch.editedName}'. Do you want to continue?", + "Continue", "Cancel"); + } + + if (canPublish) + { + InitAutonomousBuild(true); + } } - if (canPublish && CheckAccount(targetBranch)) + GUIContent autonomousBuilderButton = new GUIContent("All platforms", + BuildHelperEditorPrefs.UseAsyncPublish + ? "Publish your world for both platforms simultaneously" + : "To use the autonomous builder, please enable Async Publishing in settings"); + + if (GUILayout.Button(crossPlatformPublish, buttonStyle)) { - InitAutonomousBuild(); + Branch targetBranch = buildHelperData.CurrentBranch; + + bool canPublish = true; + if (!targetBranch.remoteExists && !targetBranch.HasVRCDataChanges()) + { + canPublish = EditorUtility.DisplayDialog("Build Helper", + $"You are about to publish a new world using the autonomous builder, but you haven't edited any world details. The autonomous builder doesn't enter playmode to let you edit world details, so your world will be uploaded as '{targetBranch.editedName}'. Do you want to continue?", + "Continue", "Cancel"); + } + + if (canPublish) + { + InitAutonomousBuild(); + } } } - } - EditorGUILayout.EndHorizontal(); + EditorGUILayout.EndHorizontal(); + } EditorGUILayout.EndVertical(); } @@ -2149,7 +2172,7 @@ private bool CheckLastBuiltBranch() currentBranch.buildData.CurrentPlatformBuildData().blueprintID; } - private static bool CheckAccount(Branch target, bool showDialog = true) + private static bool CheckAccount(Branch target) { if (target.blueprintID == "") { @@ -2160,29 +2183,12 @@ private static bool CheckAccount(Branch target, bool showDialog = true) { if (APIUser.CurrentUser.id != ((ApiWorld)model).authorId) { - if (showDialog && EditorUtility.DisplayDialog("Build Helper", - "The world author for the selected branch doesn't match the currently logged in user. Publishing will result in an error. Do you still want to continue?", - "Yes", "No")) - { - return true; - } - return false; } return true; } - - if (showDialog) - { - if (EditorUtility.DisplayDialog("Build Helper", - "Couldn't verify the world author for the selected branch. Do you want to try publishing anyways?", - "Yes", "No")) - { - return true; - } - } - + return false; } diff --git a/Packages/com.bocud.vrbuildhelper/BuildHelper/Editor/EditorCameraGUIHelper.cs b/Packages/com.bocud.vrbuildhelper/BuildHelper/Editor/EditorCameraGUIHelper.cs index 795cd01..865e9f6 100644 --- a/Packages/com.bocud.vrbuildhelper/BuildHelper/Editor/EditorCameraGUIHelper.cs +++ b/Packages/com.bocud.vrbuildhelper/BuildHelper/Editor/EditorCameraGUIHelper.cs @@ -22,6 +22,8 @@ public static void CleanupCamera() { CameraData cam = UnityEngine.Object.FindObjectOfType(); + if (cam == null) return; + if (cam.transform.parent == null) { BuildHelperData buildHelperData = BuildHelperData.GetDataBehaviour();