# \[Bug\]\[Unity\] Audio not working when calling FMOD code in OnValidate

**URL:** <https://qa.fmod.com/t/bug-unity-audio-not-working-when-calling-fmod-code-in-onvalidate/19354>\
**Category:** Unity\
**Tags:** unity\
**Created:** [October 3, 2022, 12:51pm UTC](https://qa.fmod.com/t/bug-unity-audio-not-working-when-calling-fmod-code-in-onvalidate/19354 "2022-10-03T12:51:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![adrienvr](https://avatars.discourse-cdn.com/v4/letter/a/cc9497/32.png) [@adrienvr](https://qa.fmod.com/u/adrienvr)\
**Post date:** [October 3, 2022, 12:51pm UTC](https://qa.fmod.com/t/bug-unity-audio-not-working-when-calling-fmod-code-in-onvalidate/19354/1 "2022-10-03T12:51:04Z")

</div>

Hello,  
I found a bug in the FMOD for Unity 2.02.07 (and using Unity 2021.3.5f1) that causes to have no audio in the PlayMode of Unity.  
It is basically because of a script calling RuntimeManager.StudioSystem.getParameterDescriptionByName(Parameter, out parameterDescription) in its OnValidate method.  
No error is logged, but this warning will appear after few seconds:  
[FMOD] AsyncCommandBuffer::growBuffer : Growing command buffer to 65536 bytes. Initial command buffer size can be tuned to avoid dynamic growth using Studio::System::setAdvancedSettings()  
I have uploaded the Unity and FMOD projects on my profile, with the a txt file containing the reproduction steps.  
I didn’t find how to report a bug that’s why I’m posting it here.

---

<div class="post-metadata">

**Author:** ![jeff\_fmod](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/jeff_fmod/32/1766_2.png) [@jeff\_fmod](https://qa.fmod.com/u/jeff_fmod)\
**Post date:** [October 4, 2022, 1:11am UTC](https://qa.fmod.com/t/bug-unity-audio-not-working-when-calling-fmod-code-in-onvalidate/19354/2 "2022-10-04T01:11:50Z")

</div>

It is best not to call the `RuntimeManager` from editor-only methods. In this case where you are wanting to lookup an `EventDescription` during `OnValidate` you can use the `EditorUtils.System` instead. This is the `System` object we use to support editor-only features in the FMOD Unity integration. You will need balanced calls to `EditorUtils.LoadPreviewBanks` and `EditorUtils.UnloadPreviewBanks` to access any bank data but it will otherwise give you access to the FMOD API in the same way the RuntimeManager does. Here is a modified `OnValidate` method based off of your reproduction:

```auto
private void OnValidate()
{
    if (!string.IsNullOrEmpty(Parameter))
    {
        EditorUtils.LoadPreviewBanks();
        EditorUtils.System.getParameterDescriptionByName(Parameter, out _parameterDescription);
        EditorUtils.UnloadPreviewBanks();
    }
}

```

I don’t think there is any good reason to call the `RuntimeManager` from an editor-only method and it can cause a lot of problems, so I have passed a suggestion along to the dev team to limit `RuntimeManager` access to when the Application is playing.
