Ejemplo n.º 1
0
        void Awake()
        {
            if (Application.isPlaying) {
                instance = this;
                DontDestroyOnLoad (gameObject);
            }

            bgm = gameObject.GetComponent<AudioSource> ();
            if (bgm == null) {
                bgm = gameObject.AddComponent<AudioSource> ();
            }
            bgm.loop = true;

            if (sound == null) {
                GameObject gObj = new GameObject ();
                gObj.name = "Sound";
                gObj.transform.parent = transform;
                gObj.AddComponent<Sound> ();

                sound = gObj.GetComponent<AudioSource> ();
                sound.playOnAwake = false;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Destory this instance.
 /// </summary>
 public void Destory()
 {
     instance = null;
     GameObject.Destroy (gameObject);
 }