diff --git a/Editor/Commandline.cs b/Editor/Commandline.cs index a731655..5001c63 100644 --- a/Editor/Commandline.cs +++ b/Editor/Commandline.cs @@ -1,8 +1,8 @@ -// Copyright (c) 2023 DeNA Co., Ltd. +// Copyright (c) 2023-2024 DeNA Co., Ltd. // This software is released under the MIT License. -using System.Reflection; using DeNA.Anjin.Settings; +using TestHelper.RuntimeInternals; using UnityEditor; using UnityEditor.SceneManagement; using UnityEngine; @@ -49,12 +49,12 @@ 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; + // GameView resolution set and show window even in batchmode. It can bypass batchmode limitations. e.g., WaitForEndOfFrame. + SetGameViewResolution(); + // Activate autopilot and enter play mode var state = AutopilotState.Instance; state.launchFrom = LaunchType.Commandline; @@ -85,14 +85,13 @@ private static string GetAutopilotSettingsFromArguments() return args.AutopilotSettings.Value(); } - private static void FocusGameView() + private static void SetGameViewResolution() { - 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); + var args = new Arguments(); + var width = (uint)args.GameViewWidth.Value(); + var height = (uint)args.GameViewHeight.Value(); + var name = $"{width}x{height}"; + GameViewControlHelper.SetResolution(width, height, name); } } } diff --git a/Editor/DeNA.Anjin.Editor.asmdef b/Editor/DeNA.Anjin.Editor.asmdef index 8d19fee..9c4aebb 100644 --- a/Editor/DeNA.Anjin.Editor.asmdef +++ b/Editor/DeNA.Anjin.Editor.asmdef @@ -4,8 +4,8 @@ "references": [ "UniTask", "DeNA.Anjin", - "TestHelper.Monkey.Annotations", - "TestHelper.Monkey" + "TestHelper.RuntimeInternals", + "TestHelper.Monkey.Annotations" ], "includePlatforms": [ "Editor" @@ -18,4 +18,4 @@ "defineConstraints": [], "versionDefines": [], "noEngineReferences": false -} +} \ No newline at end of file diff --git a/README.md b/README.md index 27c7285..b786aeb 100644 --- a/README.md +++ b/README.md @@ -207,6 +207,8 @@ For details on each argument, see the entry of the same name in the "Generate an
TIME_SCALE
Specifies the Time.timeScale. Default is 1.0
OUTPUT_ROOT_DIRECTORY_PATH
Output files root directory path used by Agents, Loggers, and Reporters.
SCREENSHOTS_DIRECTORY_PATH
Screenshots output directory path used by Agents.
+
GAME_VIEW_WIDTH
Set GameView width. This argument is only used to launch in editor from command line. Default is 640.
+
GAME_VIEW_HEIGHT
Set GameView height. This argument is only used to launch in editor from command line. Default is 480.
In both cases, the key should be prefixed with `-` and specified as `-LIFESPAN_SEC 60`. diff --git a/README_ja.md b/README_ja.md index 74b9343..9cff937 100644 --- a/README_ja.md +++ b/README_ja.md @@ -210,6 +210,8 @@ $(UNITY) \
TIME_SCALE
Time.timeScaleを指定します。デフォルトは1.0
OUTPUT_ROOT_DIRECTORY_PATH
Agent、Logger、および Reporter が出力するファイルのルートディレクトリパスを指定します
SCREENSHOTS_DIRECTORY_PATH
Agent が撮影するスクリーンショットの出力ディレクトリパスを指定します
+
GAME_VIEW_WIDTH
GameView の幅を設定します。この引数は、コマンド ラインからエディターを起動する場合にのみ使用されます。デフォルト値は 640 です
+
GAME_VIEW_HEIGHT
GameView の高さを設定します。この引数は、コマンド ラインからエディターを起動する場合にのみ使用されます。デフォルト値は 480 です
いずれも、キーの先頭に`-`を付けて`-LIFESPAN_SEC 60`のように指定してください。 diff --git a/Runtime/Settings/Arguments.cs b/Runtime/Settings/Arguments.cs index 3bfff63..4031989 100644 --- a/Runtime/Settings/Arguments.cs +++ b/Runtime/Settings/Arguments.cs @@ -104,5 +104,17 @@ public class Arguments /// /// public virtual IArgument SlackChannels => new Argument("SLACK_CHANNELS"); + + /// + /// GameView width. + /// This argument is only used to launch in editor from command line. + /// + public virtual IArgument GameViewWidth => new Argument("GAME_VIEW_WIDTH", 640); + + /// + /// GameView height. + /// This argument is only used to launch in editor from command line. + /// + public virtual IArgument GameViewHeight => new Argument("GAME_VIEW_HEIGHT", 480); } }