Tanoda
pb_SceneLoader.cs
Go to the documentation of this file.
1using UnityEngine;
2using System.Collections;
3using GILES;
4#if !UNITY_5_2
5using UnityEngine.SceneManagement;
6#endif
7
8namespace GILES.Example
9{
13 public class pb_SceneLoader : pb_MonoBehaviourSingleton<pb_SceneLoader>
14 {
16 public override bool dontDestroyOnLoad { get { return true; } }
17
19 public string sceneToLoadLevelInto = "Empty Scene";
20
21 [HideInInspector] [SerializeField] private string json = null;
22
26 public static void LoadScene(string path)
27 {
28 string san = pb_FileUtility.SanitizePath(path, ".json");
29
30 if(!pb_FileUtility.IsValidPath(san, ".json"))
31 {
32 Debug.LogWarning(san + " not found, or file is not a JSON scene.");
33 return;
34 }
35 else
36 {
37 instance.json = pb_FileUtility.ReadFile(san);
38 }
39
40 SceneManager.LoadScene(instance.sceneToLoadLevelInto);
41 }
42
43 private void OnLevelWasLoaded(int i)
44 {
45 if( SceneManager.GetActiveScene().name == sceneToLoadLevelInto && !string.IsNullOrEmpty(json))
46 pb_Scene.LoadLevel(json);
47 }
48 }
49}
UnityEngine.Debug Debug
Definition: TanodaServer.cs:19
override bool dontDestroyOnLoad
Make this object persistent between scene loads.
string sceneToLoadLevelInto
The scene that will be opened and loaded into.
static void LoadScene(string path)
static void LoadLevel(string levelJson, bool ssol=false)
Definition: pb_Scene.cs:238