SHARE
TWEET

Untitled

a guest Jul 21st, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top