Skip to content

Plugin for playing 2D sounds and music in games based on Unity.

License

Notifications You must be signed in to change notification settings

RodionLodza/SoundAndMusicSystem

Repository files navigation

SoundAndMusicSystem

Plugin for playing 2D sounds and music in games based on Unity.

Watch on GitHub Star on GitHub
<< How to use | Install | Download >>

How to use

  1. Create in Assets/SoundAndMusicSystem/Scripts/SoundsAndMusicDB.cs new enums items for SoundType, MusicType.
namespace SoundAndMusic
{
    public enum SoundType
    {
        None = 0,
        PlayerAttack = 1
    }

    public enum MusicType
    {
        None = 0,
        TownMusic = 1
    }
}
  1. Attach to Assets/SoundAndMusicSystem/Resources/SoundsAndMusicDB.asset some sounds and music with enum items.

0

  1. Add to game scene Assets/SoundAndMusicSystem/Prefabs/SoundAndMusicController.prefab (better where the game is loading). You can set up audio sources count, sound and music volumes in inspector.

1 2

  1. Use API SoundAndMusicController for playing sounds and music in your custom scripts.
using SoundAndMusic;
using UnityEngine;

public class SomeController : MonoBehaviour
{
    private void Start()
    {
        PlayBackgroudMusic();
        PlaySomeSound();
    }
    
    private void PlayBackgroudMusic()
    {
        SoundAndMusicController.Instance.PlayBackgroundMusic(MusicType.TownMusic);
    }
    
    private void PlaySomeSound()
    {
        SoundAndMusicController.Instance.PlaySoundAudio(SoundType.PlayerAttack);
    }
}
  1. Also you can use another public API for volume setting (SetSoundVolumeAudioSources, SetVolumeBackGroundMusic) and for stopping all sounds/music (StopAllAudioSource).

How to install

Download SoundAndMusicSystem.unitypackage and using UnityPackageManager.

License

About

Plugin for playing 2D sounds and music in games based on Unity.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages