// Use this for initialization

	void Start () {
		//singleton
		if (inst == null) {
			inst = this;
		} else {
			Destroy (this.gameObject);
		}
		//builds this audiosource and sets it all up
		if (this.GetComponent<AudioSource> () == null) {
			this.gameObject.AddComponent<AudioSource> ();
			source = this.gameObject.GetComponent<AudioSource> ();
			source.loop = true;
			source.clip = backgroundTrack;
			source.Play ();
		}
		DontDestroyOnLoad (this.gameObject);

	}
Beispiel #2
0
    // Use this for initialization

    void Start()
    {
        //singleton
        if (inst == null)
        {
            inst = this;
        }
        else
        {
            Destroy(this.gameObject);
        }
        //builds this audiosource and sets it all up
        if (this.GetComponent <AudioSource> () == null)
        {
            this.gameObject.AddComponent <AudioSource> ();
            source      = this.gameObject.GetComponent <AudioSource> ();
            source.loop = true;
            source.clip = backgroundTrack;
            source.Play();
        }
        DontDestroyOnLoad(this.gameObject);
    }