예제 #1
0
    void Awake()
    {
        if (music == null)
        {
            DontDestroyOnLoad(gameObject);                                  //makes gameObject persist between level loads
            music = this;                                                   //sets this instance as the only instance
        }
        else if (music != this)
        {
            Destroy(gameObject);                                              //if its not the only instance, destroy it
        }
        activeTheme = themes[initialActiveTheme];
        foreach (AudioSource A in gameObject.GetComponents <AudioSource>())
        {
            AudioChannels.Add(A);
        }
        activeAudioChannel    = AudioChannels[0];
        crossfadeAudioChannel = AudioChannels[1];

        if (playOnAwake)
        {
            play(initialActiveTrack);
        }
    }
예제 #2
0
    void Awake()
    {
        if (music == null)
        {
            DontDestroyOnLoad(gameObject);                                  //makes gameObject persist between level loads
            music = this;                                                    //sets this instance as the only instance
        }
        else if (music != this)
        {
            Destroy(gameObject);                                              //if its not the only instance, destroy it
        }
        activeTheme = themes[initialActiveTheme];
        foreach (AudioSource A in gameObject.GetComponents<AudioSource>())
        {
            AudioChannels.Add(A);
        }
        activeAudioChannel = AudioChannels[0];
        crossfadeAudioChannel = AudioChannels[1];

        if (playOnAwake)
        {
            play(initialActiveTrack);
        }
    }