[Unity] Allow Steam Audio to load but not run on unsupported platform or when STEAMAUDIO_ENABLED define symbol is not present. #280
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
in 4.4.1, STEAMAUDIO_ENABLED was added to indicate Steam Audio is present in the project and it is on a supported platform.
However, in a lot of cases, most Steam Audio components will still present in the scenes and prefabs, which would create a lot of broken prefabs and missing scripts for existing project to port onto a unsupported platform.
By wrapping all Steam Audio code in STEAMAUDIO_ENABLED besides serialized fields in components, we can stop Steam Audio from ever running while keeping all the prefab and serialized data intact when switching platforms without losing components or data.
As a bonus, this also prevents Steam Audio from running in Dedicated Server build since it is not a "supported platform" with STEAMAUDIO_ENABLED symbol enabled even though the binary can be bundled.
This however does not mean a fallback to unity audio or fmod, it is still up to the developer to make sure they config and play the audio accordingly (and maybe strip unused SteamAudio data when building). But it would be much easier to get started without having to manually remove all existing Steam Audio components just to make the errors go away.
The C# targeted platform is also restored to all platforms since the code can dry run and it is designed to keep the components.