From 7f493f682503f5186308de7b8f74b5b49233cfe4 Mon Sep 17 00:00:00 2001 From: chai <215380520@qq.com> Date: Thu, 2 Nov 2023 11:51:31 +0800 Subject: +init --- GameCode/LoadSceneOnTop.cs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 GameCode/LoadSceneOnTop.cs (limited to 'GameCode/LoadSceneOnTop.cs') diff --git a/GameCode/LoadSceneOnTop.cs b/GameCode/LoadSceneOnTop.cs new file mode 100644 index 0000000..c514abe --- /dev/null +++ b/GameCode/LoadSceneOnTop.cs @@ -0,0 +1,25 @@ +using UnityEngine; +using UnityEngine.SceneManagement; + +public class LoadSceneOnTop : MonoBehaviour +{ + [SerializeField] + private string sceneNameToLoad; + + private void Start() + { + LoadScene(); + } + + public void LoadScene() + { + if (!string.IsNullOrEmpty(sceneNameToLoad)) + { + SceneManager.LoadScene(sceneNameToLoad, LoadSceneMode.Additive); + } + else + { + Debug.LogError("Scene name is not specified. Please provide a valid scene name."); + } + } +} -- cgit v1.1-26-g67d0