Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. public class dontStopAudio : MonoBehaviour {
  2.  
  3. void Awake()
  4. {
  5. GameObject[] objs = GameObject.FindGameObjectsWithTag("BGAudio");
  6. if (objs.Length > 1)
  7. Destroy(this.gameObject);
  8.  
  9. DontDestroyOnLoad(this.gameObject);
  10. }
  11.  
  12. }
  13.  
  14. using System;
  15. using System.Collections;
  16. using System.Collections.Generic;
  17. using UnityEngine;
  18. using UnityEngine.UI;
  19.  
  20. public class toggleMusic : MonoBehaviour {
  21.  
  22. public GameObject bgMusic;
  23. public AudioSource bgAudio;
  24. public GameObject toggleMusicButton;
  25. public Sprite soundON, soundOFF;
  26.  
  27.  
  28. public void bgMusicOnOff()
  29. {
  30. bgAudio = bgMusic.GetComponent<AudioSource>();
  31. if (bgAudio.mute = false) {
  32. bgAudio.mute = true;
  33. toggleMusicButton.GetComponent<Image>().sprite = soundOFF;
  34. }
  35. else if (bgAudio.mute = true) {
  36. bgAudio.mute = false;
  37. toggleMusicButton.GetComponent<Image>().sprite = soundOFF;
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement