using UnityEngine; using UnityEngine.SceneManagement; /// /// This script loads the persistent managers and gameplay Scenes, to allow to start the game from any gameplay Scene /// It can also be used for menu scene by just adding the persistent managers scene on the inspector /// public class EditorInitialisationLoader : MonoBehaviour { #if UNITY_EDITOR public GameSceneSO[] scenesToLoad; public int targetFramerate = 0; // For debugging purposes //add bool and access it from other script [Header("Broadcasting on")] [SerializeField] private VoidEventChannelSO _OnEditorInitializer = default; private void Start() { Application.targetFrameRate = targetFramerate; // For debugging purposes for (int i = 0; i < SceneManager.sceneCount; ++i) { Scene scene = SceneManager.GetSceneAt(i); for (int j = 0; j < scenesToLoad.Length; ++j) if (scene.path == scenesToLoad[j].scenePath) { return; } else { SceneManager.LoadSceneAsync(scenesToLoad[j].scenePath, LoadSceneMode.Additive); //Inform that we are pressing play from a location or menu _OnEditorInitializer.RaiseEvent(); } } } #endif }