Skip to content

A simple unity audio system which is easy to use and user friendly.

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE.meta
Notifications You must be signed in to change notification settings

mohakdev/Unity-Audio-System

Repository files navigation

Unity Audio System

Table of contents

  1. Description
  2. Install
  3. How to use
  4. License

Description

Simple, lightweight and Easy to use audio system for your own game in Unity Game Engine.


Install

  • use the command at your desired download location

git clone https://github.com/mohakdev/Unity-Audio-System.git

  • Once installed open the repository folder in Unity FolderImage
  • Drag the Audio System GameObject into your first scene of the game DragPrefab
  • Go to Scripts/SoundClips.cs AudioManagerDir
  • Find SoundTypes enum. This is the place where you need to enter all the types of sound you want to play. SoundTypesEnum
  • Once added go back to Inspector, Click on AudioSystem GameObject and find Audio List. AudioList
  • Drag & Drop the sounds you want to play when a certain Sound Type is called. DragDropAudio
  • Once all the audios are dragged and dropped you will be finished with the installation.

How to Use

Namespace usage

In whichever script you wanna play audio simply add

using RadiantTools.AudioSystem;

Note -> If you are using Assembly Definitions then don't forget to add this assembly as a reference.

Components of Audio System

Audio Manager -> It controls and manages all the existing audio players. You can make or delete or get audio players using AudioManager.cs

Audio Player -> Basically it controls an audio track. It is nothing but a script attached to a gameobject with AudioSource as a component. You can play Audio using a Audio Player. By default 2 AudioTracks exists which are Music and SoundSFX. Music Track has settings to make audio loop forever. While Ideally you should use SoundSFX to play one shot sounds like button click or victory sound etc. For more sounds like for example walking, car engine sound or something it is ideal to make your own custom audio track using Audio Manager. Heirarchy

Play One Shot Sounds

AudioPlayer soundSFX = AudioManager.Instance.GetAudioPlayer("SoundSFX");
soundSFX.PlayAudioOnce(SoundTypes.AudioOne);

//Using Custom Player to Play One Shot Sounds
AudioPlayer customPlayer = AudioManager.Instance.MakeAudioPlayer("Test");
customPlayer.PlayAudioOnce(SoundTypes.AudioOne);

Play using Custom Sounds

To Play continuous sounds like walking , car engine use a custom track and manage it settings that way

AudioPlayer customPlayer = AudioManager.Instance.MakeAudioPlayer("Test");
customPlayer.SetAudioClip(customPlayer.GetAudioClip(SoundTypes.AudioTwo));
customPlayer.SetAudioSettings(loop: true);
customPlayer.PlayAudio();

Change Audio Player Settings

//Changing settings of audio as well
customPlayer.SetAudioSettings(loop: true, startOnPlay : true, volume : 1, pitch : 1);

License

This code is licensed under MIT License which you can read here

About

A simple unity audio system which is easy to use and user friendly.

Topics

Resources

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE.meta

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages