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
- [UI Toolkit] ScrollView scroll offset gets reset to 0 when resetting DisplayStyle from Flex to None to Flex
- Model previews do not update when navigating the "Import Unity Package" window using the arrow keys
- [Windows] Hold on is being shown after switching platform and only disappears after hovering on the window
- Editor hangs on Domain Reload when there is recursion in SerializeReference class structure
- Crash on D3D12 when entering Play Mode in High Definition 3D Core project's Environment scene
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.