Can't check EventInstance for null in 1.10.2

As the subject says, since 1.10.x we can’t check FMOD.Studio.EventInstance for null anymore.

Assets/Scripts/BaseEnergyBeam.cs(75,13): error CS0019: Operator !=' cannot be applied to operands of typeFMOD.Studio.EventInstance’ and `null’

Never mind, found it.

Apparently you folks changed EventInstances from classes to structs.

Would be nice if the release notes would reflect these kind of major changes (would also be nice if you would actually have release notes to begin with…or a manual or api reference that isn’t always out of date by at least 2 versions.)

1 Like

I didn’t even know C# supported structs. Glad you asked this question. I was stumped.

The latest release notes (1.10.00) can be found here:

1 Like

How does one check if an EventInstance exists after this change as a struct is never null?

eg. I want to check if it already exists before creating a new one.

You don’t, since a struct is a value type it is always initialized, thus never null.

There are some easy ways to check though.

What we do now in our wrappers is when creating an eventIinstance is simply checking that the event string or guid being assigned to that new event instance passes a IsNullOrEmpty check.
If you don’t do this an try to create and instance it will thow an exception (default FMOD behaviour.)

If you want to check if you created an EventInstance without using the build in CreateInstance or attach sound what not methods, simply trying to get anything from it (say, getEventDescription for example), would return with an ERR_INVALID_HANDLE result.

If you where to check for the ID of the event attached to an instance without an event and would regard all RESULT states returned by the methods (EventDescriptor.getID) your event ID would result in a ‘00000000-0000-0000-0000-000000000000’ GUID

So, not sure what the official method is, but there’s plenty ways to check for valid event instances.

1 Like

To add to what @houseofsecrets said, the C# wrapper structs also contain a isValid() function that null checks the handle and for Studio objects checks them against the Studio System.