- Home /
Change defaults for standard components
I had a request from one of my team-members to change the default values for AudioSource components when they are created. For example, he wants the volume to default to 0.75 instead of 1, or the 'Play On Awake' to default to off. Is there some way to get this to happen?
If not, I can setup a button or menu-option to create a component and set the settings myself, but if there's a better way I'd like to use it.
Answer by Martijn Hendriks · Oct 01, 2011 at 08:15 AM
You can have these settings set automatically via a script. You can then find the AudioSource component attached to the same game object and alter its variables in the Awake method of your script. This however leads to your own prefab of a sound object (game object with an AudioSource and your script) that must be used by your team members. Maybe not the best solution, but it provides some flexibility when you have your own control over this sound prefab.
This is pretty much what I ended up with - my system was actually a little more complicated, but I ended up with a separate (custom) class that had the same fields (plus some extras for my use case) with the defaults more appropriate to our use, and then those would be copied to the AudioSource at runtime.
Your answer
![](https://koobas.hobune.stream/wayback/20220612232139im_/https://answers.unity.com/themes/thub/images/avi.jpg)