# Find unused events

**URL:** <https://qa.fmod.com/t/find-unused-events/23076>\
**Category:** Unity\
**Created:** [June 24, 2025, 8:23am UTC](https://qa.fmod.com/t/find-unused-events/23076 "2025-06-24T08:23:08Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![marko.ravnjak](https://avatars.discourse-cdn.com/v4/letter/m/c67d28/32.png) [@marko.ravnjak](https://qa.fmod.com/u/marko.ravnjak)\
**Post date:** [June 24, 2025, 8:23am UTC](https://qa.fmod.com/t/find-unused-events/23076/1 "2025-06-24T08:23:08Z")

</div>

Not sure if I missed there or not, is there a way to find which events in project are currently not being used? So, they are not linked via EventReference?

---

<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:** [June 26, 2025, 12:07am UTC](https://qa.fmod.com/t/find-unused-events/23076/3 "2025-06-26T00:07:07Z")

</div>

Hi,

Could I grab some more info? Is this just events that haven’t been played, or events that have not been assigned to an emitter or being referenced by an `EventReference`?

Thanks!

---

<div class="post-metadata">

**Author:** ![marko.ravnjak](https://avatars.discourse-cdn.com/v4/letter/m/c67d28/32.png) [@marko.ravnjak](https://qa.fmod.com/u/marko.ravnjak)\
**Post date:** [July 14, 2025, 12:40pm UTC](https://qa.fmod.com/t/find-unused-events/23076/4 "2025-07-14T12:40:37Z")

</div>

Hi,  
sry for late reply (summer vacation)…

Yes, I’m simply looking for info, if an event is actually referenced. Goal is to to find unused events and then go bother audio artists to remove them (reduce build size).

---

<div class="post-metadata">

**Author:** ![marko.ravnjak](https://avatars.discourse-cdn.com/v4/letter/m/c67d28/32.png) [@marko.ravnjak](https://qa.fmod.com/u/marko.ravnjak)\
**Post date:** [July 14, 2025, 12:49pm UTC](https://qa.fmod.com/t/find-unused-events/23076/5 "2025-07-14T12:49:51Z")

</div>

I did a quick and (really) dirty hax on EventReferenceUpdater, which first collects all references and then checks it against current studio cache. It kinda works, but I broke a few things along the way, hence searching for a more proper solution 🙂

---

<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 15, 2025, 2:34am UTC](https://qa.fmod.com/t/find-unused-events/23076/6 "2025-07-15T02:34:17Z")

</div>

Thanks for the info.

That is not a feature we currently have but I will pass it onto our development team to investigate further.

If you could share you updated `EventReferenceUpdater.cs` and the issues it is having we could try fix that in the mean time?

---

<div class="post-metadata">

**Author:** ![marko.ravnjak](https://avatars.discourse-cdn.com/v4/letter/m/c67d28/32.png) [@marko.ravnjak](https://qa.fmod.com/u/marko.ravnjak)\
**Post date:** [July 15, 2025, 7:04am UTC](https://qa.fmod.com/t/find-unused-events/23076/7 "2025-07-15T07:04:58Z")

</div>

I’ve added another func

```auto
        private void BeginSearchingForUnused()
        {
            var eventCacheGuids = AssetDatabase.FindAssets("t:EventCache");
            if (eventCacheGuids.Length == 0)
            {
                return;
            }

            var referencedGuids = new HashSet<Guid>();
            foreach (var task in tasks)
            {
                var g = new Guid(task.DataPublic[task.DataPublic.Length - 1]);
                referencedGuids.Add(g);
            }

            var eventCache = AssetDatabase.LoadAssetAtPath<EventCache>(AssetDatabase.GUIDToAssetPath(eventCacheGuids[0]));
            for (var index = 0; index < eventCache.EditorEvents.Count; index++)
            {
                var editorEvent = eventCache.EditorEvents[index];
                EditorUtility.DisplayProgressBar($"Searching {index} of {eventCache.EditorEvents.Count - 1}", editorEvent.Path, (float)index / eventCache.EditorEvents.Count - 1);

                if (referencedGuids.Contains(editorEvent.Guid))
                {
                    continue;
                }

                Debug.LogError($"FMOD Event is not referenced: {editorEvent.Path}");
            }

            EditorUtility.ClearProgressBar();
            StopProcessing(true);
        }

```

But I 've had some issues when logic was parsing serialized data, had to add this to handle some arrays/lists I think…

```auto
private static IEnumerable<Task> GetGenericUpdateTasks(object target, string subObjectPath = null, IEnumerable<object> parents = null)
        {
            Type targetType = target.GetType();

            if (targetType == typeof(EventReference))
            {
                EventReference eventReference = (EventReference)target;
                Task updateTask = GetUpdateEventReferenceTask(eventReference, subObjectPath, subObjectPath);
                if (updateTask != null)
                {
                    yield return updateTask;
                }
            }

            FieldInfo[] fields = targetType.GetFields(DefaultBindingFlags);

```

And a few try/catch handlers along the way 🙂

I then “broke” this:

```auto
private static Task GetUpdateEventReferenceTask(EventReference eventReference, string fieldName,
            string subObjectPath = null)
        {
            if (eventReference.IsNull)
            {
                return null;
            }

            if (Settings.Instance.EventLinkage == EventLinkage.GUID)
            {
                EditorEventRef editorEventRef = EventManager.EventFromGUID(eventReference.Guid);

                if (editorEventRef == null)
                {
                    return null;
                }

                // !!!! force true to enumerate everything...
                if (eventReference.Path != editorEventRef.Path || true)
                {
                    return Task.UpdateEventReferencePath(subObjectPath, fieldName, eventReference.Path,
                        editorEventRef.Path, eventReference.Guid);
                }
            }

```

In the end I ran the update task first, which just collected everything, and then run my custom task to check against the cache…

Like I said, kinda works, but ugly…

---

<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 18, 2025, 1:50am UTC](https://qa.fmod.com/t/find-unused-events/23076/8 "2025-07-18T01:50:58Z")

</div>

Thank you for the code snippets, I’m having some issues integrating that into my own script. Would it be possible to get the full script uploaded to your [profile](https://fmod.com/profile#uploads) for me to test?

---

<div class="post-metadata">

**Author:** ![marko.ravnjak](https://avatars.discourse-cdn.com/v4/letter/m/c67d28/32.png) [@marko.ravnjak](https://qa.fmod.com/u/marko.ravnjak)\
**Post date:** [July 18, 2025, 8:29am UTC](https://qa.fmod.com/t/find-unused-events/23076/9 "2025-07-18T08:29:27Z")

</div>

it’s up

---

<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, 2025, 6:37am UTC](https://qa.fmod.com/t/find-unused-events/23076/10 "2025-07-23T06:37:44Z")

</div>

Hi, apologies for the delayed response.

I have added your script to the task but I haven’t ironed the issues yet. I will update you as soon as I can.
