Hola gente, para hacer esto que pregunto he pensado que podría hacerlo así:
using UnityEngine;
using System.Collections;
public class audio : MonoBehaviour {
private GameObject[] _go;
private AudioSource _as;
void Start () {
_go = GameObject.FindGameObjectsWithTag ("Audio");
for (int i = 0; i < _go.Length; i++)
{
_as = _go.GetComponent<AudioSource> ();
}
}
}
Pero la consola me marcar este error:
(14,25): error CS0021: Cannot apply indexing with [] to an expression of type `UnityEngine.AudioSource'
He intentado hacer diferentes cosas pero como soy todavía novato en la programación, no sé solucionarlo. Gracias de antemano por la ayuda.
AudioSource _as; //Variable del tipo audio source.
AudioSource[] _as; //Array de audio source.
_as = new AudioSource[_go.length];