-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSimpleAudioWrapper.cs
More file actions
40 lines (31 loc) · 1.24 KB
/
SimpleAudioWrapper.cs
File metadata and controls
40 lines (31 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* Simple Audio Wrapper between Wwise and Unity Audio
*
* Currently only supports playing AudioClip instead of Wwise event.
* Fake random containers coming at some point.
*
* Usage:
* - Add SimpleAudioWrapperSoundBank script to a game object in scene
* - Add AudioClips to SimpleAudioWrapperSound AudioClips array. Names must match Wwise events!
* - When you wish to play audio using wrapper use PlayAudioEvent function. It will automatically
* play either Wwise event or audio clip based on active platform.
* Like this: SimpleAudioWrapper.PlayAudioEvent("Play_test_event", gameObject);
* - Game objects must have audiosources!
* - Default config assumes only WebGL uses Unity native audio.
*
* Works in tandem with AudioSystemSwitcher (ASSAudioSystemSwitcher.cs)
*/
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public static class SimpleAudioWrapper
{
public static void PlayAudioEvent(string audioEvent, GameObject gObject)
{
#if NO_WWISE
gObject.GetComponent<AudioSource>().PlayOneShot(SimpleAudioWrapperSoundBank.instance.GetAudioClipByName(audioEvent));
#else
AkSoundEngine.PostEvent(audioEvent, gObject);
#endif
}
}