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
- Template is opened in Isolation when opening it in Context and users Save the UI Document when prompted to do so in UI Builder
- Mono Windows Builds don't produce full log callstacks when generating logs
- AssetBundles fail to load when running in Built Players for Mobile Devices
- UI elements with text gets bigger and grey when Player window is moved to another screen with different resolution
- System name accepts multiline text but crops it on confirmation, duplicates input, and shrinks the field when empty
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.