Skip to content

Instantly share code, notes, and snippets.

@tsuzukihashi
Last active August 31, 2019 06:57
Show Gist options
  • Save tsuzukihashi/326cb3e3f67b6645dade24a14a52dc49 to your computer and use it in GitHub Desktop.
Save tsuzukihashi/326cb3e3f67b6645dade24a14a52dc49 to your computer and use it in GitHub Desktop.
Unity 全シーン管理マネージャーの作成 ref: https://qiita.com/tsuzukihashi/items/1d8a9fce4465c688c78a
using UnityEngine;
public class DDManager : MonoBehaviour {
public GameObject gameObject;
void Start () {
DontDestroyOnLoad(gameObject);
}
}
using UnityEngine;
using UnityEngine.SceneManagement;
public class ManagerSceneAutoLoader : MonoBehaviour {
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
private static void LoadManagerScene(){
string managerSceneName = "ManagerScene";
//ManagerSceneが有効でないときに追加ロード
if(!SceneManager.GetSceneByName(managerSceneName).IsValid()){
SceneManager.LoadScene(managerSceneName, LoadSceneMode.Additive);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment