Example #1
0
    //o Update é activado uma vez por frame:
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit))
            {
                if (hit.collider.tag == "Play")
                {
                    //Este segmento desactiva o botão play, reproduz o ficheiro e activa o botão para pausar.
                    BPlay.SetActive(false);
                    BPause.SetActive(true);
                    MusicHolder.GetComponent <AudioSource>().Play();
                }

                if (hit.collider.tag == "Pause")
                {
                    //Este segmento desactiva o botão pausar, pára o ficheiro e activa o botão play.
                    BPause.SetActive(false);
                    BPlay.SetActive(true);
                    MusicHolder.GetComponent <AudioSource>().Stop();
                }
            }
        }
    }
Example #2
0
 public static MusicHolder GetInstance()
 {
     if (Instance == null)
     {
         Instance = new MusicHolder();
     }
     return(Instance);
 }
Example #3
0
    // Use this for initialization
    void Start()
    {
        rend     = GetComponent <Renderer>();
        holder   = musicObject.GetComponent <MusicHolder>();
        thisClip = holder.GetClip(notePosition);
        Debug.Log(thisClip);

        playing = false;
    }
 void Awake()
 {
     if (_instance)
     {
         Destroy(gameObject);
         return;
     }
     DontDestroyOnLoad(gameObject);
     _source = GetComponent <AudioSource>();
     _source.outputAudioMixerGroup.audioMixer.GetFloat("MusicVolume", out _wantedVolume);
     _instance = this;
 }
Example #5
0
 protected void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Destroy(gameObject);
     }
 }
Example #6
0
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(this.gameObject);
         return;
     }
     else
     {
         instance = this;
     }
     DontDestroyOnLoad(this.gameObject);
 }
Example #7
0
    private void Awake()
    {
        DontDestroyOnLoad(transform.gameObject);
        _audioSource = GetComponent <AudioSource>();

        if (thisInstance == null)
        {
            thisInstance = this; PlayMusic();
        }
        else
        {
            Destroy(gameObject);
        }
    }
Example #8
0
 private void OnDestroy()
 {
     musicSoundInstance.stop(FMOD.Studio.STOP_MODE.ALLOWFADEOUT);
     Instance = null;
 }