Safely check whether an event exists to avoid crashes in live build

I’ve been searching for a solution on this but have been unable to find any way to do it. Hoping I’ve just missed something obvious.

We have a lot of sounds in the game, and some categories of SFX are set up and assigned via our external sheets. We have a pretty safe database generator so no manual strings are being entered anywhere for FMOD events, but things can still slip through the cracks from time to time (it’s happened a few times already, and we’re still in alpha).

My expectation was that the API would let me do something like
if(!CheckEventExists("some event")) return;
So that as an absolute worst case, a mistake in event path/bank contents would result in silence, not an app crash when CreateInstance() is called on a bad string.

Can’t seem to find anything like that, so I’m hoping others that may be in a similar situation (or have been) might be able to shed light on best practices. Would just like to reduce FMOD’s/game-sound’s chances of crashing (via human error on content) the app to 0%.

ok… typically, some continue digging after posting this turned up what I needed.

In case it helps anyone else:
RuntimeManager.StudioSystem.getEvent(id, out desc);

then check .isValid() on out desc object.

If, like in our project, you’re building event paths or managing them externally in your pipeline (e.g. vast spreadsheets of player-equipment), you can make sure your CreateInstance() calls won’t throw an exception from content mistakes.

1 Like

You could also check if getEvent returns FMOD.RESULT.OK. If the Event doesn’t exists for some reason it should return ERR_EVENT_NOTFOUND.

1 Like