2024-11-28 12:57:52 +01:00

44 lines
1.1 KiB
C#

using UnityEngine;
using UnityEngine.SceneManagement;
namespace Passer {
using Humanoid;
public class StartScene : MonoBehaviour {
public string sceneName;
private string thisSceneName;
protected void Awake() {
Scene activeScene = UnityEngine.SceneManagement.SceneManager.GetActiveScene();
thisSceneName = activeScene.name;
UnityEngine.SceneManagement.SceneManager.sceneLoaded += OnSceneLoad;
#if UNITY_6000_0_OR_NEWER
HumanoidControl pawn = FindAnyObjectByType<HumanoidControl>();
#else
HumanoidControl pawn = FindObjectOfType<HumanoidControl>();
#endif
if (pawn == null) {
UnityEngine.SceneManagement.SceneManager.LoadScene(sceneName);
}
DontDestroyOnLoad(this.gameObject);
}
private void OnSceneLoad(UnityEngine.SceneManagement.Scene _, LoadSceneMode _1) {
#if UNITY_EDITOR
#if UNITY_6000_0_OR_NEWER
SiteNavigator siteNavigator = FindAnyObjectByType<SiteNavigator>();
#else
SiteNavigator siteNavigator = FindObjectOfType<SiteNavigator>();
#endif
if (siteNavigator != null) {
siteNavigator.startScene = thisSceneName;
}
#endif
}
}
}