Ejemplo n.º 1
0
    private void Awake()
    {
        _androidBackgroundAudio = BackgroundAudioManager.NewInstance();

        _androidBackgroundAudio.OnAudioStarted += () => UnityMainThreadDispatcher.Instance().Enqueue(() => _seekBar.maxValue = _androidBackgroundAudio.GetDuration());
        _toggle.onValueChanged.AddListener(SetLooping);
    }
Ejemplo n.º 2
0
    private void Awake()
    {
        // This part helps so the sound is not breaking and starting again when changing between scenes
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
            return;
        }

        DontDestroyOnLoad(gameObject);

        // Search for the called sound in the array
        foreach (Sound s in sounds)
        {
            s.source      = gameObject.AddComponent <AudioSource>();
            s.source.clip = s.clip;

            s.source.volume = s.volume;
            s.source.pitch  = s.pitch;
            s.source.loop   = s.loop;
        }
    }
    //-----------------------------------------------------

    void Start()
    {
        instance = this;

        backgroundAudioSource = this.GetComponent <AudioSource>();

        StartCoroutine(UpdateAudio());
    }
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Ejemplo n.º 5
0
 //simple singleton, has to actually be placed
 private void Awake()
 {
     if (_inst != null)
     {
         DestroyImmediate(this);
     }
     else
     {
         _inst = this;
     }
 }
Ejemplo n.º 6
0
    private void Start()
    {
        if (instance == null)
        {
            instance = this;
            AudioSource.Stop();
            AudioSource.clip = BackgroundMusic;
            AudioSource.loop = true;
            AudioSource.Play();

            VolumeManager.instance.OnBackgroundMusicVolumeChanged += UpdateVolume;

            DontDestroyOnLoad(this.gameObject);
        }
    }
 public void SetInstance()
 {
     inst = this;
 }