Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class SoundManager : MonoBehaviour
- {
- public static SoundManager Instance { get; set; }
- // Sound FX
- public AudioSource dropItemSound;
- public AudioSource craftingSound;
- public AudioSource toolSwingSound;
- public AudioSource chopSound;
- public AudioSource pickupItemSound;
- public AudioSource grassWalkSound;
- public AudioSource treeChopSound;
- //Music
- public AudioSource startingZoneBGMusic;
- public AudioSource natureBGMusic;
- public AudioSource birdBG;
- public AudioSource bird1BG;
- public AudioSource bird2BG;
- public AudioSource bushesBG;
- public AudioSource leavesBG;
- public AudioSource voiceovers;
- private void Awake()
- {
- if (Instance != null && Instance != this)
- {
- Destroy(gameObject);
- }
- else
- {
- Instance = this;
- }
- }
- public void PlaySound(AudioSource soundToPlay)
- {
- if (!soundToPlay.isPlaying)
- {
- soundToPlay.Play();
- }
- }
- public void PlayVoiceOvers(AudioClip clip)
- {
- voiceovers.clip = clip;
- if (!voiceovers.isPlaying)
- {
- voiceovers.Play();
- }
- else
- {
- voiceovers.Stop();
- voiceovers.Play();
- }
- }
- public void StopVoiceOvers(AudioClip clip)
- {
- voiceovers.clip = clip;
- voiceovers.Stop();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement