Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class dontStopAudio : MonoBehaviour {
- void Awake()
- {
- GameObject[] objs = GameObject.FindGameObjectsWithTag("BGAudio");
- if (objs.Length > 1)
- Destroy(this.gameObject);
- DontDestroyOnLoad(this.gameObject);
- }
- }
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class toggleMusic : MonoBehaviour {
- public GameObject bgMusic;
- public AudioSource bgAudio;
- public GameObject toggleMusicButton;
- public Sprite soundON, soundOFF;
- public void bgMusicOnOff()
- {
- bgAudio = bgMusic.GetComponent<AudioSource>();
- if (bgAudio.mute = false) {
- bgAudio.mute = true;
- toggleMusicButton.GetComponent<Image>().sprite = soundOFF;
- }
- else if (bgAudio.mute = true) {
- bgAudio.mute = false;
- toggleMusicButton.GetComponent<Image>().sprite = soundOFF;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement