# How to spot empty/null EventReference?

**URL:** <https://qa.fmod.com/t/how-to-spot-empty-null-eventreference/19858>\
**Category:** Unity\
**Created:** [February 10, 2023, 2:50pm UTC](https://qa.fmod.com/t/how-to-spot-empty-null-eventreference/19858 "2023-02-10T14:50:51Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![zanardi](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/zanardi/32/1045_2.png) [@zanardi](https://qa.fmod.com/u/zanardi)\
**Post date:** [February 10, 2023, 2:50pm UTC](https://qa.fmod.com/t/how-to-spot-empty-null-eventreference/19858/1 "2023-02-10T14:50:51Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [February 12, 2023, 10:07pm UTC](https://qa.fmod.com/t/how-to-spot-empty-null-eventreference/19858/2 "2023-02-12T22:07:32Z")

</div>

Hi,

A check you could use is

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

```

Hope this helps!

---

<div class="post-metadata">

**Author:** ![zanardi](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/zanardi/32/1045_2.png) [@zanardi](https://qa.fmod.com/u/zanardi)\
**Post date:** [February 13, 2023, 1:52am UTC](https://qa.fmod.com/t/how-to-spot-empty-null-eventreference/19858/3 "2023-02-13T01:52:35Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [February 13, 2023, 2:57am UTC](https://qa.fmod.com/t/how-to-spot-empty-null-eventreference/19858/4 "2023-02-13T02:57:28Z")

</div>

No worries,

This is just checking if the `Event Path` is left empty in the Unity Editor  
 ![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/3/3d4de8591ef15bb10215f803edc517fd8cca9918.png)

```auto
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!

---

<div class="post-metadata">

**Author:** ![MatLoz](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@MatLoz](https://qa.fmod.com/u/MatLoz)\
**Post date:** [July 22, 2024, 5:46pm UTC](https://qa.fmod.com/t/how-to-spot-empty-null-eventreference/19858/5 "2024-07-22T17:46:16Z")

</div>

This works only in the editor, how do you check at runtime if an EventReference is null?

---

<div class="post-metadata">

**Author:** ![Connor\_FMOD](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/connor_fmod/32/3685_2.png) [@Connor\_FMOD](https://qa.fmod.com/u/Connor_FMOD)\
**Post date:** [July 23, 2024, 1:00am UTC](https://qa.fmod.com/t/how-to-spot-empty-null-eventreference/19858/6 "2024-07-23T01:00:01Z")

</div>

Hi,

An alternative could be using [EventReference.isNull](https://fmod.com/docs/2.02/unity/api-common.html#eventreference:~:text=public%20bool%20IsNull%0A%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20get%0A%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20string.IsNullOrEmpty(Path)%20%26%26%20Guid.IsNull%3B%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%7D).

Hope this helps!
