Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- #if UNITY_EDITOR
- using UnityEditor;
- #endif
- // @kurtdekker
- // designed to be in your content scene where you're editing the level.
- // this then loads the player, UI, pause button, music, etc.
- public class SceneLoader : MonoBehaviour
- {
- private void Reset()
- {
- name = "AdditiveSceneLoader";
- }
- const string s_LoadingPrefab = "Prefabs/Loading/Canvas_Loading_Prefab";
- public List<string> additiveScenes;
- void InitGame()
- {
- // global variables
- DSM.State.Score.iValue = 0;
- }
- IEnumerator Start()
- {
- var loading = Instantiate<GameObject>(Resources.Load<GameObject>(s_LoadingPrefab));
- InitGame();
- foreach (var additiveScene in additiveScenes)
- {
- if (string.IsNullOrEmpty(additiveScene))
- {
- continue;
- }
- SceneHelper.GotoScene(additiveScene, true);
- }
- // lets all the scenes load
- yield return null;
- Destroy(loading);
- }
- #if UNITY_EDITOR
- [CustomEditor(typeof(SceneLoader)), CanEditMultipleObjects]
- public class SceneLoaderEditor : Editor
- {
- public override void OnInspectorGUI()
- {
- SceneLoader sl = (SceneLoader)target;
- DrawDefaultInspector();
- EditorGUILayout.BeginVertical();
- if (GUILayout.Button("EMIT STRINGS TO DEBUG"))
- {
- var s = "Scenes list:\n\n";
- for (int i = 0; i < sl.additiveScenes.Count; i++)
- {
- s = s + sl.additiveScenes[i] + "\n";
- }
- Debug.Log(s);
- }
- EditorGUILayout.EndVertical();
- }
- }
- #endif
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement