Skip to content

Commit 454b0c0

Browse files
committed
fix: next scene name
1 parent f6d0ab7 commit 454b0c0

File tree

4 files changed

+25
-7
lines changed

4 files changed

+25
-7
lines changed

Assets/JCSUnity/Scripts/JCS_Logo.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public class JCS_Logo : MonoBehaviour
2020

2121
[Separator("Runtime Variables (JCS_Logo)")]
2222

23-
[Tooltip("Next scene to load.")]
23+
[Tooltip("Next scene to load; if empy, load the next scene instead.")]
2424
[SerializeField]
2525
private string mNextLevel = "JCS_AppCloseSimulate";
2626

@@ -57,7 +57,21 @@ private void Update()
5757
mDelayTimer += JCS_Time.DeltaTime(mDeltaTimeType);
5858

5959
if (mDelayTime < mDelayTimer)
60-
JCS_SceneManager.instance.LoadScene(mNextLevel);
60+
{
61+
LoadLevel();
62+
}
63+
}
64+
65+
private void LoadLevel()
66+
{
67+
var sm = JCS_SceneManager.instance;
68+
69+
string sceneName = mNextLevel;
70+
71+
if (sceneName == "")
72+
sceneName = sm.NextSceneName();
73+
74+
sm.LoadScene(sceneName);
6175
}
6276
}
6377
}

Assets/JCSUnity/Scripts/Managers/JCS_SceneManager.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* $Notice: See LICENSE.txt for modification and distribution information
77
* Copyright (c) 2016 by Shen, Jen-Chieh $
88
*/
9+
using System.IO;
910
using UnityEngine;
1011
using UnityEngine.SceneManagement;
1112
using MyBox;
@@ -505,11 +506,14 @@ public void ReloadScene(float fadeInTime, Color screenColor, bool keepBGM)
505506
/// <summary>
506507
/// Return the next scene.
507508
/// </summary>
508-
public Scene NextScene(int offset = 1)
509+
public string NextSceneName(int offset = 1)
509510
{
510511
int nextIndex = SceneManager.GetActiveScene().buildIndex + offset;
511512

512-
return SceneManager.GetSceneByBuildIndex(nextIndex);
513+
string pathToScene = SceneUtility.GetScenePathByBuildIndex(nextIndex);
514+
string sceneName = Path.GetFileNameWithoutExtension(pathToScene);
515+
516+
return sceneName;
513517
}
514518

515519
/// <summary>
@@ -600,7 +604,7 @@ public void LoadNextScene(Color screenColor, bool keepBGM)
600604
/// <param name="keepBGM"> Set to true if keep background music playing. </param>
601605
public void LoadNextScene(float fadeInTime, Color screenColor, bool keepBGM)
602606
{
603-
string sceneName = NextScene().name;
607+
string sceneName = NextSceneName();
604608

605609
LoadScene(sceneName, fadeInTime, screenColor, keepBGM);
606610
}

Assets/JCSUnity/Scripts/UI/Button/Scene/JCS_LoadSceneButton.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public override void OnClick()
7373
else
7474
{
7575
if (sceneName == "")
76-
sceneName = sm.NextScene().name;
76+
sceneName = sm.NextSceneName();
7777
}
7878

7979
sm.LoadScene(sceneName, mScreenColor, mKeppBGM);

Assets/JCSUnity/Scripts/UI/Button/Scene/JCS_LoadSceneGamePadButton.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public override void OnClick()
7373
else
7474
{
7575
if (sceneName == "")
76-
sceneName = sm.NextScene().name;
76+
sceneName = sm.NextSceneName();
7777
}
7878

7979
sm.LoadScene(sceneName, mScreenColor, mKeppBGM);

0 commit comments

Comments
 (0)