Skip to content

Commit 929bf81

Browse files
authored
Update README.md
1 parent 36314cb commit 929bf81

1 file changed

Lines changed: 51 additions & 1 deletion

File tree

.github/README.md

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Audio Solution for Unity
2-
This asset provides an easy solution for **playing audio clips, sound effects and music** without needing to worry about managing Audio Sources.
2+
This asset provides an easy solution for **playing audio clips, sound effects and music** without needing to worry about managing Audio Sources. I've designed it to be simply plug-and-play with no setup required.
3+
4+
Features:
5+
- Play an audio clip at any time and control playback without worrying about Audio Sources.
6+
- Play a music track, automatically fading in and out between tracks.
7+
- Create - and play - sound effect assets, assisting in setting up specific types of sounds (e.g. footsteps, gunshots, etc.)
8+
- Play audio clips, music and sound effects easily from the Unity Resources folder.
9+
- Helpful audio-related functions.
310

411
## Setup
512
Simply import the package into your project and you're good to go. No additional setup is required.
@@ -8,3 +15,46 @@ Simply import the package into your project and you're good to go. No additional
815
- Git URL: ``https://github.com/DavidF-Dev/Unity-Audio.git``</br>
916
<img src="/.github/install1.png" alt="Package manager install" width="25%"></src>
1017
- <i>Or</i> add the following line to <i>Packages/manifest.json</i>:</br>``"com.davidfdev.audio": "https://github.com/DavidF-Dev/Unity-Audio.git"``
18+
19+
## Usage
20+
No setup is required. To access the scripts, include the ``DavidFDev.Audio`` namespace at the top of your file. The core functionality of the asset is contained in the ``Audio`` static class, which exposes methods for playing audio clips, sound effects & music.
21+
- ``Play(AudioClip, Position [optional], AudioMixerGroup [optional])``: play the provided audio clip.
22+
- ``Play(Path, Position [optional], AudioMixerGroup[optional])``: play an audio clip loaded from the Resources folder.
23+
- ``PlaySfx(SoundEffect, Position [optional])``: play the provided sound effect.
24+
- ``PlaySfx(Path, Position [optional])``: play a sound effect loaded from the Resources folder.
25+
- ``PlayMusic(AudioClip, FadeIn, FadeOut)``: play the provided music track.
26+
- ``PlayMusic(Path, FadeIn, FadeOut)``: play a music track loaded from the Resources folder.
27+
28+
</br>Calling ``Play()`` or ``PlaySfx()`` will return an instance of Playback which allows control of the Audio Source indirectly.
29+
E.g.
30+
```cs
31+
Playback playback = Audio.PlaySfx(sfx);
32+
playback.Pause();
33+
playback.Volume = 0.4f;
34+
playback.Loop = true;
35+
```
36+
37+
</br>Sound effects are scriptable objects that can be added to your Assets. They are used for setting up specific types of sounds. An instance can be played by calling the ``Play()`` method or by passing it in to ``Audio.PlaySfx()``.
38+
39+
### Examples
40+
```cs
41+
Audio.Play("Audio/death_scream", enemy.position);
42+
```
43+
This call will load the `death_scream` Audio Clip from the Resources folder and play it at the enemy's position.
44+
</br></br>
45+
```cs
46+
Audio.PlayMusic(music, fadeIn: 1f, fadeOut: 0.75f);
47+
Debug.Log($"Current music track: {Audio.CurrentMusic.name}");
48+
```
49+
Playing a music track will crossfade the new track with the old track, if one was already playing. The currently playing music track can be queried through ``Audio.CurrentMusic``.
50+
</br></br>
51+
```cs
52+
Playback playback = Audio.Play(clip, position: new Vector3(0f, 1f, 0f), output: output);
53+
playback.ForceFinish();
54+
```
55+
An Audio Mixer Group can be provided to control where the audio signal is routed. Also, a sound can be stopped prematurely by calling ``ForceFinish()`` on the Playback instance. Note that - unlike with Audio Sources - Playback instances cannot be replayed once the audio has finished playing.
56+
57+
## Contact
58+
If you have any questions or would like to get in contact, shoot me an email at contact@davidfdev.com. Alternatively, you can send me a direct message on Twitter at [@DavidF_Dev](https://twitter.com/DavidF_Dev).</br></br>
59+
Consider showing support by [buying me a bowl of spaghetti](https://www.buymeacoffee.com/davidfdev) 🍝</br>
60+
View my other Unity tools on my [website](https://www.davidfdev.com/tools) 🔨

0 commit comments

Comments
 (0)