How to spot empty/null EventReference?

Hi there! I’m using a public FMODUnity.EventReference to hold reference to a sound, but I’m leaving the path empty since I dont have the sound yet.

I’m trying to not call it if it’s null by calling EventReference.IsNull but, it returns not-null. The path is empty on my Unity Editor, but Debug.Log returns a GUID for this EventReference, so it’s not-null.

Is something I’m missing?

Hi,

A check you could use is

if (reference.Path.Length > 0)
{
    Debug.Log("Path");
}
else
    Debug.Log("No path");

Hope this helps!

Hi Connor, thanks for the reply!

I’m not exactly sure if it would work, since the Path value is not used outside the Unity Editor, right?

No worries,

This is just checking if the Event Path is left empty in the Unity Editor
image

public FMODUnity.EventReference reference;
// Start is called before the first frame update
void Start()
{
    if (reference.Path.Length > 0)
    {
        Debug.Log("Path");
    }
    else
        Debug.Log("No path");
}

The script will just need a reference to the Event Reference.

Hope this helps!