I’ve got an EventInstance that plays indefinitely. Stopping it with OnDestroy is great, except when you’re stopping Unity and your StudioSystem gets (sometimes) killed before your EventInstance, and then trying to stop your Event crashes Unity completely.

Here’s your fix.

So, as usual I’ve got things like:

[code:3p3l0nsl]FMOD_StudioSystem soundSystem;
FMOD.Studio.EventInstance zoom;

void Start () {
//my StudioSystem is attached to my main camera, which is great
// ..but also causes my Unity to crash indirectly
soundSystem = cam.GetComponent<initSoundSystem>().soundSystem;
zoom = soundSystem.getEvent("/Rocks/rockShoot");

void OnDestroy()
//do check to work while game is running and prevent crash when stopping Unity
if (soundSystem!=null && soundSystem.System.isValid())

Also, per usual with me, this is probably not the 100% correct path, but all of this stuff is hard to find and I hope this helps someone. Have fun.

  • You must to post comments
Showing 0 results
Your Answer

Please first to submit.