Last active
August 29, 2015 14:14
-
-
Save kawai-hiroyuki/bcc1197636b1b62e5525 to your computer and use it in GitHub Desktop.
シーンを遷移してもBGMを継続して再生する方法 ref: http://qiita.com/hiroyuki7/items/b11496a3b72e89affdd0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 () { | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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