diff --git a/Editor/Commandline.cs b/Editor/Commandline.cs index daa1d22..998dcd6 100644 --- a/Editor/Commandline.cs +++ b/Editor/Commandline.cs @@ -2,6 +2,7 @@ // This software is released under the MIT License. using System.Diagnostics.CodeAnalysis; +using System.Reflection; using DeNA.Anjin.Settings; using UnityEditor; using UnityEditor.SceneManagement; @@ -49,6 +50,9 @@ private static void Bootstrap() return; } + // Show GameView window even in batchmode. It can bypass batchmode limitations. e.g., WaitForEndOfFrame. + FocusGameView(); + // Set first open Scene EditorSceneManager.playModeStartScene = myWantedStartScene; @@ -84,5 +88,15 @@ private static string GetAutopilotSettingsFromArguments() return args.AutopilotSettings.Value(); } + + private static void FocusGameView() + { + var assembly = Assembly.Load("UnityEditor.dll"); + var viewClass = Application.isBatchMode + ? "UnityEditor.GameView" + : "UnityEditor.PlayModeView"; + var gameView = assembly.GetType(viewClass); + EditorWindow.GetWindow(gameView, false, null, true); + } } } diff --git a/README.md b/README.md index 47bc86f..4bdfa73 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,7 @@ It is **NOT** set to `DontDestroyOnLoad`. #### Autopilot Run Settings -This item can also be overridden from the command line (see below). +This item can also be overridden from the commandline (see below).
Lifespan
Specifies the execution time limit in seconds. Defaults to 300 seconds, 0 specifies unlimited operation
@@ -176,6 +176,7 @@ To execute from the commandline, specify the following arguments. ```bash $(UNITY) \ -projectPath $(PROJECT_HOME) \ + -batchmode \ -executeMethod DeNA.Anjin.Editor.Commandline.Bootstrap \ -AUTOPILOT_SETTINGS Assets/Path/To/AutopilotSettings.asset ``` @@ -183,7 +184,7 @@ $(UNITY) \ - `UNITY` is the path to the Unity editor, and `PROJECT_HOME` is the root of the project to be autorun. - `-AUTOPILOT_SETTINGS` is the path to the settings file (AutopilotSettings) you want to run. - Do not specify `-quit` (it will exit without entering play mode). -- `-batchmode` will not work with the PlaybackAgent and MonkeyAgent in games that use uGUI. +- Do not specify `-nographics` (do not show GameView window). In addition, some settings can be overridden by adding the following arguments. For details on each argument, see the entry of the same name in the "Generate and configure the AutopilotSettings.asset file" mentioned above. @@ -425,8 +426,17 @@ Run the command below: git submodule add https://github.com/dena/Anjin.git Packages/com.dena.anjin ``` -> **Note** -> Required install [Unity Test Framework](https://docs.unity3d.com/Packages/com.unity.test-framework@latest) package v1.3 or later for running tests. +> [!WARNING] +> Required install packages for running tests (when adding to the `testables` in package.json), as follows: +> - [Unity Test Framework](https://docs.unity3d.com/Packages/com.unity.test-framework@latest) package v1.3.4 or later +> - [Test Helper](https://github.com/nowsprinting/test-helper) package v0.4.2 or later + +Generate a temporary project and run tests on each Unity version from the command line. + +```bash +make create_project +UNITY_VERSION=2019.4.40f1 make -k test +``` ## Release workflow diff --git a/README_ja.md b/README_ja.md index 3b53578..c1ca332 100644 --- a/README_ja.md +++ b/README_ja.md @@ -175,6 +175,7 @@ Slack通知に付与するメンションを設定します。 ```bash $(UNITY) \ -projectPath $(PROJECT_HOME) \ + -batchmode \ -executeMethod DeNA.Anjin.Editor.Commandline.Bootstrap \ -AUTOPILOT_SETTINGS Assets/Path/To/AutopilotSettings.asset ``` @@ -184,7 +185,7 @@ $(UNITY) \ - `UNITY`にはUnityエディタへのパス、`PROJECT_HOME`には自動実行対象プロジェクトのルートを指定します - `-AUTOPILOT_SETTINGS` には、実行したい設定ファイル(AutopilotSettings)のパスを指定します - `-quit` は指定しないでください(Play modeに入らず終了してしまいます) -- `-batchmode` ではuGUIを使用しているゲームでは、PlaybackAgentおよびMonkeyAgentが動作しません +- `-nographics` は指定しないでください(GameViewウィンドウを表示できません) また、以下の引数を追加することで一部の設定を上書きできます。 各引数の詳細は前述の「オートパイロット設定ファイル」の同名項目を参照してください。 @@ -429,8 +430,17 @@ Pull requestには `enhancement`, `bug`, `chore`, `documentation` といった git submodule add https://github.com/dena/Anjin.git Packages/com.dena.anjin ``` -> **Note** -> Anjinパッケージ内のテストを実行するために、[Unity Test Framework](https://docs.unity3d.com/Packages/com.unity.test-framework@latest) パッケージ v1.3以上が必要です。 +> [!WARNING] +> Anjinパッケージ内のテストを実行するためには、次のパッケージのインストールが必要です。 +> - [Unity Test Framework](https://docs.unity3d.com/Packages/com.unity.test-framework@latest) package v1.3.4 or later +> - [Test Helper](https://github.com/nowsprinting/test-helper) package v0.4.2 or later + +テスト専用のUnityプロジェクトを生成し、Unityバージョンを指定してテストを実行するには、次のコマンドを実行します。 + +```bash +make create_project +UNITY_VERSION=2019.4.40f1 make -k test +``` ## リリースワークフロー diff --git a/Runtime/Reporters/SlackMessageSender.cs b/Runtime/Reporters/SlackMessageSender.cs index c97eb7f..1109d3f 100644 --- a/Runtime/Reporters/SlackMessageSender.cs +++ b/Runtime/Reporters/SlackMessageSender.cs @@ -92,7 +92,7 @@ public async UniTask Send( return; } - if (withScreenshot && !Application.isBatchMode) + if (withScreenshot) { var coroutineRunner = new GameObject().AddComponent(); await UniTask.WaitForEndOfFrame(coroutineRunner); diff --git a/Tests/Runtime/DeNA.Anjin.Tests.asmdef b/Tests/Runtime/DeNA.Anjin.Tests.asmdef index 81b5e7f..305ae96 100644 --- a/Tests/Runtime/DeNA.Anjin.Tests.asmdef +++ b/Tests/Runtime/DeNA.Anjin.Tests.asmdef @@ -7,7 +7,8 @@ "DeNA.Anjin", "DeNA.Anjin.Annotations", "UniTask", - "DeNA.Anjin.Editor" + "DeNA.Anjin.Editor", + "TestHelper" ], "includePlatforms": [], "excludePlatforms": [], diff --git a/Tests/Runtime/Reporters/SlackMessageSenderTest.cs b/Tests/Runtime/Reporters/SlackMessageSenderTest.cs index 359ac18..6c95b01 100644 --- a/Tests/Runtime/Reporters/SlackMessageSenderTest.cs +++ b/Tests/Runtime/Reporters/SlackMessageSenderTest.cs @@ -8,6 +8,7 @@ using System.Threading.Tasks; using DeNA.Anjin.TestDoubles; using NUnit.Framework; +using TestHelper.Attributes; namespace DeNA.Anjin.Reporters { @@ -83,6 +84,7 @@ await sender.Send( } [Test] + [FocusGameView] public async Task WithScreenshot() { var spySlackAPI = new SpySlackAPI();