Class ButtonAudio
Behaviour that associates a sound to a button. Just by adding this component, everything is set up.
Namespace: GGL.Audio
Assembly: GGL.dll
Syntax
[RequireComponent(typeof(Button))]
[AddComponentMenu("GG-Library/UI/Audio/Button Audio")]
[HelpURL("https://ggl.yoannhaffner.com/articles/audio.html#configuration")]
public class ButtonAudio : MonoBehaviour
Fields
| Edit this page View Sourceclip
Declaration
[ShowIf("mode", ButtonAudio.Mode.DEFAULT)]
[SerializeField]
protected AudioClip clip
Field Value
Type | Description |
---|---|
AudioClip | In DEFAULT mode, audio file to play. |
mode
Declaration
[SerializeField]
protected ButtonAudio.Mode mode
Field Value
Type | Description |
---|---|
ButtonAudio.Mode | Define how the script will behaviour to play an audio file. |
source
Declaration
[ShowIf("mode", ButtonAudio.Mode.CUSTOM)]
[SerializeField]
protected AudioSource source
Field Value
Type | Description |
---|---|
AudioSource | In CUSTOM mode, AudioSource to play. |
volume
Declaration
[ShowIf("mode", ButtonAudio.Mode.DEFAULT)]
[SerializeField]
protected float volume
Field Value
Type | Description |
---|---|
float | In DEFAULT mode, volume to play the audio file. |
Methods
| Edit this page View SourcePlaySound()
Play a sound depending on the mode. Defaultly called by the associated button once clicked.
Declaration
public virtual void PlaySound()