Search Issue Tracker
By Design
Votes
0
Found in
2019.4
2020.3
2020.3.0f1
2021.1
2021.2
2022.1
Issue ID
1347374
Regression
No
OnActiveBuildTargetChanged not called in batch mode
Reproduction steps:
1. Download the attached user's project "switchPlatform.zip"
2. Run "{path to Unity} -batchmode -nographics -quit -buildTarget Android -projectPath {project path} -executeMethod SwitchPlatformTest.LogSomething" in the Windows Command Prompt
3. Inspect the Editor log
Expected result: when running Unity in batchmode with the -buildTarget argument, Editor Log "LogSomething" is being correctly logged, but not the one in OnActiveBuildTargetChanged
Actual result: when running Unity in batchmode with the -buildTarget argument, IActiveBuildTargetChanged.OnActiveBuildTargetChanged is not called.
Reproduces on: 2019.4.29f1, 2020.3.14f1, 2021.1.14f1, 2021.2.0b3, 2022.1.0a2
Notes:
-Observe the message in the Editor Log "LogSomething" being correctly logged, but not the one in OnActiveBuildTargetChanged
-From the user's information, this is also reproducible on macOS
-SwitchPlatformTest.cs
public static void LogSomething()
{
Debug.Log("###LOG: Here's something to log: Something");
}
public int callbackOrder => 0;
public void OnActiveBuildTargetChanged(BuildTarget previousTarget, BuildTarget newTarget)
{
Debug.Log($"###LOG: ActiveBuildTargetChanged called from {previousTarget} to {newTarget}");
}
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- "No HDR monitor detected." warning is shown in the Rendering Debugger even when the Editor is on HDR-enabled monitor
- Shader Graph Enum Keyword Default Value changes after reordering Entries
- Light Explorer throws “ArgumentException” error when disabling all columns from the Multi-column panel context menu
- "Freeze Camera For Culling" options are inconsistent between the Game view overlay and Rendering Debugger window
- Crash on GetOriginalSourceOrVariantRoot when creating a scene from a specific template
Resolution Note:
This is actually by design, and not related to batchmode: running "{path to Unity} -buildTarget Android -projectPath {project path}" has the same behaviour.
This event can only be raised when the build target is changed while the project is loaded. The command line argument sets the build target even before the project is loaded, so for the perspective of the user code there is no change: even before the project is loaded, it has been compiled for the specified build target.
We opened a ticket to make the documentation about the event explicit about not covering -builtTarget argument.