Esempio n. 1
0
    void Start()
    {
        GameObject music = GameObject.FindGameObjectWithTag("Music");

        if (music != null)
        {
            musicPlayer mp = music.GetComponent <musicPlayer>();
            mp.PlayMusic();
        }
    }
Esempio n. 2
0
 // Use this for initialization
 void Awake()
 {
     //		If we haven't had a music player before, create a musicPlayer and assign the instance to it. otherwise, destroy this
     if (musicPlayer.instance != null) {
         Debug.Log ("Destroying duplicate musicPlayer");
         Destroy (gameObject);
     } else {
         musicPlayer.instance = this;
         GameObject.DontDestroyOnLoad (gameObject);
     }
 }
Esempio n. 3
0
 void Awake()
 {
     if (instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
         GameObject.DontDestroyOnLoad(gameObject);
     }
 }
Esempio n. 4
0
 // Use this for initialization
 void Start()
 {
     if (instance == null)
     {
         instance = new musicPlayer();
         GameObject.DontDestroyOnLoad(instance);
     }
     else
     {
         Destroy(instance);
     }
 }
Esempio n. 5
0
 void Awake()
 {
     if (instance != null)
     {
         Destroy(gameObject);
         print("duplicate musicPlayer destroyed");
     }
     else
     {
         instance = this;
         GameObject.DontDestroyOnLoad(gameObject);
     }
 }
Esempio n. 6
0
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(gameObject);
         return;
     }
     else
     {
         instance = this;
     }
     DontDestroyOnLoad(gameObject);
 }
Esempio n. 7
0
    void Awake()
    {
        DontDestroyOnLoad(this);
        _audioSource = GetComponent <AudioSource>();

        if (musicPlayerInstace == null)
        {
            musicPlayerInstace = this;
        }
        else
        {
            DestroyObject(gameObject);
        }
    }
Esempio n. 8
0
 void Awake()       //put int awake will make music flow stimutaneously
 {
     Debug.Log("Music player Awake " + GetInstanceID());
     if (instance != null)           //prevent new musicplayer is created(If another scene has music player or move back to start menu)
     {
         Destroy(gameObject);
         Debug.Log("Duplicate music player self-destructing!");             //make new music get destroy before run start
     }
     else
     {
         instance = this;
         GameObject.DontDestroyOnLoad(gameObject);
         Debug.Log("Music created!!!");
     }
 }
Esempio n. 9
0
    void Awake()
    {
        //if we don't have an [_instance] set yet
        if (!_instance)
        {
            _instance = this;
        }
        //otherwise, if we do, kill this thing
        else
        {
            Destroy(this.gameObject);
        }


        DontDestroyOnLoad(this.gameObject);
    }
Esempio n. 10
0
    // Use this for initialization
    void Start()
    {
        if (instance != null && instance != this)
        {
            Destroy(gameObject);
            print("Duplicate music player self-destructing");
        }
        else
        {
            instance = this;
            GameObject.DontDestroyOnLoad(gameObject);

            music      = GetComponent <AudioSource>();
            music.clip = startClip;
            music.loop = true;
            music.Play();
        }
    }