# The serializedObject should not be used inside OnSceneGUI or OnPreviewGUI. Use the target property directly instead

**URL:** https://qa.fmod.com/t/the-serializedobject-should-not-be-used-inside-onscenegui-or-onpreviewgui-use-the-target-property-directly-instead/17319
**Category:** Unity
**Tags:** unity
**Created:** [June 10, 2021, 11:08am UTC](https://qa.fmod.com/t/the-serializedobject-should-not-be-used-inside-onscenegui-or-onpreviewgui-use-the-target-property-directly-instead/17319 "2021-06-10T11:08:53Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![DryreL](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/dryrel/32/2334_2.png) [@DryreL](https://qa.fmod.com/u/DryreL)
#### Post date: [June 10, 2021, 11:08am UTC](https://qa.fmod.com/t/the-serializedobject-should-not-be-used-inside-onscenegui-or-onpreviewgui-use-the-target-property-directly-instead/17319/1 "2021-06-10T11:08:53Z")

</div>

Hello, today I started to using FMod however I’m getting error when I play the audio in Unity. Audio plays for 1-2 seconds but then suddenly Unity gives error.

Unity 2021.1.7f1  
FMod 2.01.10 Build #116632

! [image\_2021-06-10\_130702|690x125](https://qa.fmod.com/uploads/short-url/uG5zXSZZwDfpXkz6vlYX9998RkQ.png)

! [image\_2021-06-10\_130734|400x467](https://qa.fmod.com/uploads/short-url/4oNiihPJdt6NKkN2Eu6JaePfS4n.png)

 ![image_2021-06-10_130813](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/2/24cc4f16491963c7eb42f916f8126a4360396e2c.png)

Thanks in advance.

---

<div class="post-metadata">

### Author: ![DryreL](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/dryrel/32/2334_2.png) [@DryreL](https://qa.fmod.com/u/DryreL)
#### Post date: [June 12, 2021, 5:12pm UTC](https://qa.fmod.com/t/the-serializedobject-should-not-be-used-inside-onscenegui-or-onpreviewgui-use-the-target-property-directly-instead/17319/2 "2021-06-12T17:12:44Z")

</div>

If I disable that gameobject, audio stops playing (ofc) and error is gone.

![image_2021-06-10_130734](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/1/1ed6391fe1e54dfa34e7591e3b114165b5f4dfdf.png)

This problem is related to this script. Any solution?

---

<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: [June 16, 2021, 5:26am UTC](https://qa.fmod.com/t/the-serializedobject-should-not-be-used-inside-onscenegui-or-onpreviewgui-use-the-target-property-directly-instead/17319/3 "2021-06-16T05:26:53Z")

</div>

Can you please provide some steps to reproduce the error and send though the entire output log for one of those errors?
