protected void Awake() { _audioLoader = GetComponent<Uzu.AudioLoader> (); _audioController = this.gameObject.AddComponent<Uzu.AudioController> (); // Initialize audio controller. { Uzu.AudioControllerConfig config = new Uzu.AudioControllerConfig (); config.AudioSourceMaxCount = MAX_AUDIO_SOURCES; config.AudioLoader = _audioLoader; _audioController.Initialize (config); } }
protected void Awake() { _audioLoader = GetComponent <Uzu.AudioLoader> (); _audioController = this.gameObject.AddComponent <Uzu.AudioController> (); // Initialize audio controller. { Uzu.AudioControllerConfig config = new Uzu.AudioControllerConfig(); config.AudioSourceMaxCount = MAX_AUDIO_SOURCES; config.AudioLoader = _audioLoader; _audioController.Initialize(config); } }
/// <summary> /// Initializes the audio controller. /// </summary> public void Initialize(AudioControllerConfig config) { // AudioSource allocation. { int maxCount = Mathf.Max (1, config.AudioSourceMaxCount); _availableSources = new FixedList<AudioSource> (maxCount); _availableSourceInfoIndices = new FixedList<int> (maxCount); _activeSourceInfoIndices = new FixedList<int> (maxCount); _sourceInfos = new FixedList<AudioSourceInfo> (maxCount); for (int i = 0; i < maxCount; i++) { GameObject go = new GameObject ("AudioSource_" + i); Transform xform = go.transform; xform.parent = this.transform; AudioSource audioSource = go.AddComponent<AudioSource> (); ReturnSourceToPool (audioSource); _availableSourceInfoIndices.Add (i); _sourceInfos.Add (new AudioSourceInfo ()); } } _audioLoader = config.AudioLoader; if (_audioLoader == null) { Debug.LogError ("AudioLoader not set!"); } }