Skip to content
Aprius edited this page Aug 28, 2024 · 5 revisions

Screenshot_12

To manage audio, you first need to go through AudioManager. This component should be mounted in the Persistent Scene according to the scene-flow.

image

  • The properties of AudioManger are:

    • Player Prefab : Prefab of AudioPlayer, Each sound that needs to be played will be performed by an AudioPlayer. image
    • Audio Asset: ScriptableObject contains all Audio Data

Usages

To use this we will first need to create an AudioData via menu Create > Pancake > AudioData

image

You can also use Ctrl + D to duplicate an existing audio data but this time its Id will not be automatically regenerated so you need to regenerate it by right clicking on it.

image

  • There are two main types of Type: SFX and Music.

  • You can play multiple sounds at the same time through the same AudioData by adding elements to Groups, each group will have a list of clips, the clip to be played will be selected based on Sequence Mode.

  • Each group will have a Cooldown To Play option to avoid playing too many similar sounds at once

  • Next we will declare an AudioId property

[SerializeField, AudioPickup] private AudioId bgm;
  • Now we can select AudioData through Inspector, If you don't see AudioData in the drop-down window, it means that AudioData has not been added to AudioAsset, you can add it using the AddToAudioAsset button in that AudioData or the LoadAll button to add all available AudioData in AudioAsset

image

bgm.Play();
bgm.Play().QuietOthers(0.5f, 0.2f, 1f);
bgm.Stop();
bgm.Pause();
bgm.Resume();


AudioStatic.StopAll();
AudioStatic.StopAllByType(EAudioType.Sfx);
Clone this wiki locally