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
- “Remove Unused Overrides” available on not loaded Scene and throws “ArgumentException: The scene is not loaded” warning
- Adaptive Probe Volume occlusion edge is calculated incorrectly when viewing probes near geometry edges
- Sampling a texture using an HLSL file throws shader errors and the code does not compile
- "Graphics.CopyTexture called with null source texture" error when Base Camera of an Overlay Camera is removed with DX11 Graphics API and Compatibility Mode enabled
- WebGL sends wrong value with large numbers when SendMessage function is used
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.