Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- using UnityEngine.SceneManagement;
- public class ExtrasScript : MonoBehaviour
- {
- public static bool didFinish = false;
- public Button soundBtn;
- public Text btnTxt;
- public AudioClip sound1;
- private AudioSource audioSource;
- private AudioSource themeSource;
- public void BackMenu ()
- {
- if (!audioSource.isPlaying)
- {
- SceneManager.LoadScene ("Menu");
- }
- }
- public void PlaySound ()
- {
- themeSource.Pause ();
- if (!audioSource.isPlaying)
- {
- audioSource.PlayOneShot (sound1);
- }
- }
- void Start ()
- {
- audioSource = GetComponent<AudioSource> ();
- themeSource = GameObject.Find ("Music Player").GetComponent<AudioSource> ();
- if (didFinish == false)
- {
- soundBtn.interactable = false;
- btnTxt.text = "Complete Game to UNLOCK";
- }
- else if (didFinish == true)
- {
- soundBtn.interactable = true;
- btnTxt.text = "Play Sound";
- audioSource.Stop ();
- }
- }
- void Update ()
- {
- if (didFinish == true)
- {
- if (audioSource.isPlaying)
- {
- btnTxt.text = "Sound is Playing";
- }
- else if (!audioSource.isPlaying)
- {
- themeSource.Play ();
- btnTxt.text = "Play Sound";
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement