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

        if (music != null)
        {
            musicPlayer mp = music.GetComponent <musicPlayer>();
            mp.PlayMusic();
        }
    }
Exemplo 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);
     }
 }
Exemplo n.º 3
0
 void Awake()
 {
     if (instance != null)
     {
         Destroy(gameObject);
     }
     else
     {
         instance = this;
         GameObject.DontDestroyOnLoad(gameObject);
     }
 }
Exemplo n.º 4
0
 // Use this for initialization
 void Start()
 {
     if (instance == null)
     {
         instance = new musicPlayer();
         GameObject.DontDestroyOnLoad(instance);
     }
     else
     {
         Destroy(instance);
     }
 }
Exemplo n.º 5
0
 void Awake()
 {
     if (instance != null)
     {
         Destroy(gameObject);
         print("duplicate musicPlayer destroyed");
     }
     else
     {
         instance = this;
         GameObject.DontDestroyOnLoad(gameObject);
     }
 }
Exemplo n.º 6
0
 void Awake()
 {
     if (instance != null && instance != this)
     {
         Destroy(gameObject);
         return;
     }
     else
     {
         instance = this;
     }
     DontDestroyOnLoad(gameObject);
 }
Exemplo n.º 7
0
    void Awake()
    {
        DontDestroyOnLoad(this);
        _audioSource = GetComponent <AudioSource>();

        if (musicPlayerInstace == null)
        {
            musicPlayerInstace = this;
        }
        else
        {
            DestroyObject(gameObject);
        }
    }
Exemplo 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!!!");
     }
 }
Exemplo 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);
    }
Exemplo 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();
        }
    }