So this is a fun one. Unity 6000.6.0, FMOD 2.03.14
We have some build profiles:
Windows64,
Switch2
The Editor is set to Windows64 build profile.
We want to build the Switch2 platform in batchMode using -activeBuildProfile “SomeProfile.asset”
After adding some logs into FMOD, I noticed that UNITY_SWITCH2 is not defined at the point platform build targets are registered.
For example:
RuntimeUtils.BuildLog($"Active Build Target: {EditorUserBuildSettings.activeBuildTarget}", LogType.Log);
RuntimeUtils.BuildLog($"Active Build Profile: {UnityEditor.Build.Profile.BuildProfile.GetActiveBuildProfile()?.name}", LogType.Log);
#if UNITY_SWITCH2
RuntimeUtils.BuildLog("UNITY_SWITCH2 IS DEFINED", LogType.Log);
#else
RuntimeUtils.BuildLog("UNITY_SWITCH2 IS NOT DEFINED", LogType.Error);
#endif
Results in these logs:
[FMOD Build] Active Build Target: Switch2
[FMOD Build] Active Build Profile: NintendoSwitch
[FMOD Build] UNITY_SWITCH2 IS NOT DEFINED
And looking at the PlatformSwitch2 impl:
internal override IEnumerable<BuildTarget> GetBuildTargets()
{
#if UNITY_SWITCH2
yield return BuildTarget.Switch2;
#elif UNITY_OUNCE
yield return BuildTarget.Ounce;
#else
yield return BuildTarget.NoTarget;
#endif
}
Means that the Switch2 platform is not registered and the build fails with:
BuildFailedException: No FMOD platform found for build target Switch2. You may need to install a platform specific integration package from https://www.fmod.com/download.
Seems like PlatformSwitch2 could just return BuildTarget.Switch2?