I would like enable it by scripting, but if I type like
if (!this.BancoDeSonidos[0].GetComponent<AudioSource>().isPlaying)
{
if (!this.BancoDeSonidos[0].GetComponent<AudioSource>().enabled==true)
BancoDeSonidos[0].GetComponent<AudioSource>().Play();
}
I get same, “Can not play a disabled audio source”. So, I don’t understand it.
Why does it execute Play() if it is not enabled?
Objects must be in the scene to work. You can’t play an audiosource on a prefab that hasn’t been instantiated into a scene, because it’s “nowhere” and can’t do anything.
This. Prefabs aren’t real GameObjects. They are just a set of text data that tells Unity how to build a real GameObject.
They are a blueprint if you like. You can use blueprints for lots of things. You can even make a full building form them. But standing on the elevator in the blueprint isn’t going to get you off the ground.
Thank you very much. It is another option. In fact, I would like to attach all the sounds that the player can make in a its GameObject. I don´t like the hierarchy’s visual full with audios. It sees out like there’s not organization.
Another option is an empty static GameObject managing the sounds, but, I don’t want to use it so far.