Skip to content

Instantly share code, notes, and snippets.

@kawai-hiroyuki
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kawai-hiroyuki/bcc1197636b1b62e5525 to your computer and use it in GitHub Desktop.
Save kawai-hiroyuki/bcc1197636b1b62e5525 to your computer and use it in GitHub Desktop.
シーンを遷移してもBGMを継続して再生する方法 ref: http://qiita.com/hiroyuki7/items/b11496a3b72e89affdd0
using UnityEngine;
using System.Collections;
public class MainSoundScript : MonoBehaviour {
public bool DontDestroyEnabled = true;
// Use this for initialization
void Start () {
if (DontDestroyEnabled) {
// Sceneを遷移してもオブジェクトが消えないようにする
DontDestroyOnLoad (this);
}
}
// Update is called once per frame
void Update () {
}
}
if ( Input.GetKeyDown(KeyCode.A) == true ) {
Debug.Log("Now scene is " + Application.loadedLevelName);
// Aキーを押すとシーンが遷移する
Application.LoadLevel("Scene2");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment