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
- Texture2D hash changes inside of an AssetBundle when rebuilding a SpriteAtlas bundle with an empty AssetPostprocessor Script enabled
- Aniso Level still applies when Generate MipMap is disabled in Texture Import Settings
- Mipmap Limit Groups long names are not truncated when creating a new Mipmap Limit Group with a long name
- “ArgumentException: Invalid double parameter.” error is thrown when Infinity is typed into the Fixed Timestep field
- GameObject becomes gray when using HDRP and STP together on macOS
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.