Skip to content
This repository was archived by the owner on Aug 24, 2025. It is now read-only.

AudioManager & Sounds #29

Description

@DerTyp7

The function of the AudioManager is to manage/play sound clips.
The Sound-Class stores all AudioSources (just sounds) in an object so the AudioManager can work with them.

The AudioManager will get instantiated ONLY in the HomeScene (via DoNotDestroy) → so if you don't start from the HomeScene, the AudioManager may not work properly!!!

Make sure to add/remove sounds in the prefab and not in the GameObject → so they get saved directly to the prefab

Add a sound

Paste your AudioFile in the folder: "Assets/Audios".
To add a sound, just go to the AudioManager GameObject Prefab and add a new item to the "sounds-list".

Delete a sound

To delete a sound, just go to the AudioManager GameObject Prefab and delete the item of the "sounds-list".

Play a sound

If you want to play a sound, access the current AudioManager and call the "Play(string name)"-method.
This method searches for a sound by the name and plays it for you.

This easiest way to do this is: FindObjectOfType<AudioManager>().Play(name);

This function will not crash the game if the sound was not found, but cause a warning

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions