public SoundPlayer(byte[] data) { gameObject = new GameObject("Sound"); AudioSource source = gameObject.AddComponent <AudioSource>(); source.clip = AudioCompression.Decompress(data, gameObject.AddComponent <CoroutineMonoBehaviour>()); source.Play(); }
public void Init() { audioSource = gameObject.AddComponent <AudioSource>(); audioSource.volume = 0; audioSource.loop = playMode == PlayMode.LOOP || playMode == PlayMode.BKGND; audioSource.playOnAwake = false; if (soundData.bytes.Length == 0) { return; } audioSource.clip = AudioCompression.Decompress(soundData.bytes, this); if (playMode != PlayMode._1SHOT) { StartCoroutine(VolumeUpdateCoroutine()); } }
public void Init() { audioSource = gameObject.AddComponent <AudioSource>(); audioSource.volume = 0; audioSource.loop = playMode == PlayMode.LOOP || playMode == PlayMode.BKGND; audioSource.spatialBlend = spatial ? 1.0f : 0.0f; if (spatial) { audioSource.minDistance = minDistance; audioSource.spread = spatialMode == SpatialSoundMode.AMBIENT ? 180 : 0; } audioSource.playOnAwake = false; if (soundData.bytes.Length == 0) { return; } audioSource.clip = AudioCompression.Decompress(soundData.bytes, this); if (playMode != PlayMode._1SHOT) { StartCoroutine(VolumeUpdateCoroutine()); } }