Unity-Technologies / NativeAudioPlugins

MIT License
135 stars 28 forks source link

iOS build instructions #16

Open cheesymoo opened 1 week ago

cheesymoo commented 1 week ago

The provided documentation is lacking detail on how to load a Spatializer Plugin on a Unity app that target iOS.

The only working solution has been provided by the community: (via: https://discussions.unity.com/t/native-audio-plugin-bundle-does-not-work-on-ios/767945/3)

extern "C" {
// We have to manually register the Unity Audio Effect plugin.
struct UnityAudioEffectDefinition;
typedef int (*UnityPluginGetAudioEffectDefinitionsFunc)(
struct UnityAudioEffectDefinition*** descptr);
extern void UnityRegisterAudioPlugin(
UnityPluginGetAudioEffectDefinitionsFunc getAudioEffectDefinitions);
extern int UnityGetAudioEffectDefinitions(UnityAudioEffectDefinition*** definitionptr);

} // extern "C"

- (void)shouldAttachRenderDelegate {}
- (void)preStartUnity {
UnityRegisterAudioPlugin(UnityGetAudioEffectDefinitions);
}

Is this the recommended approach by Unity?

Earlier documentation suggests that the prefix audioplugin is sufficient for the plugins to be loaded, but this does not seem to the the case on embedded platforms.

cheesymoo commented 1 week ago

To clarify, I am not talking about how to compile the native plugin for iOS. I am talking about this runtime error given by iOS apps:

Audio source failed to initialize audio spatializer. An audio spatializer is specified in the audio project settings, but the associated plugin was not found or initialized properly. Please make sure that the selected spatializer is compatible with the target.