- Home /
how can i make prefabs keep there inspector varibles
So if i have a script on a prefab and have something in the script like public AudioSource CoinSoundEffect; and I set that and apply to my prefab why doesn't that stay when i use copies of the prefabs?
Can you explain the situation a bit more specifically please? Where are these prefabs and where is the audiosource that you drag to them? How do you make copies of them and do the variables lose values when you press play or when making copies?
you can always show the important parts of the script ;-) I think you might have set the audiosource to null at initialization, awake or start, but some code snippet would really help ;-)
Are you sure about that? Everytime i drag a copy of one of my prefabs into a scene, they keep the same variables as the original gameobject.
Answer by z3 · Apr 10, 2017 at 12:40 PM
they keep everything but the audio source, I guess it might be because the audio source is on another game object. anyways solved it by just telling the other game object to play the sound via script. thanks