Skip to content

Commit

Permalink
fix(Pause): Fix unreasonable pause while switching scene
Browse files Browse the repository at this point in the history
  • Loading branch information
jcs090218 committed Jul 30, 2023
1 parent 547428b commit d35e761
Show file tree
Hide file tree
Showing 10 changed files with 1,428 additions and 1,157 deletions.
16 changes: 12 additions & 4 deletions Assets/JCSUnity/Resources/JCS_Managers.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 4bbeb25e792087645b19e4cf30c3218a, type: 3}
m_Name:
m_EditorClassIdentifier:
mTestWithKey: 0
mToggleGamePause: 112
TIME_SCALE: 1
mGamePause: 0
mGameDoneInitialize: 0
--- !u!114 &11439248
Expand All @@ -160,12 +157,12 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 06ceabc1c1c745c44a60262572a8c61b, type: 3}
m_Name:
m_EditorClassIdentifier:
mSwitchSceneType: 1
mBlackScreen: {fileID: 0}
mBlackSlideScreen: {fileID: 0}
mAlign: 0
mPopWhiteScreen: 1
mWhiteScreen: {fileID: 0}
mSwitchSceneType: 1
mPauseGameWhileLoadingScene: 1
mOverrideSetting: 0
mSceneFadeInTime: 1
Expand Down Expand Up @@ -400,8 +397,19 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: aa49b5ee139699040b4a44e97ef334aa, type: 3}
m_Name:
m_EditorClassIdentifier:
mTimeScale: 1
mTestWithKey: 0
mToggleGamePause: 112
mIncTime: 110
mDecTime: 109
mTimeDelta: 5
mTargetTimeScale: 1
mPauseActions: []
mDefaultTimeScale: 1
mResizePauseActionListTime: 20
mOverrideSetting: 0
mAsymptotic: 0
mFriction: 0.2
--- !u!1 &1678435913
GameObject:
m_ObjectHideFlags: 0
Expand Down
14 changes: 0 additions & 14 deletions Assets/JCSUnity/Scripts/JCS_Logo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ public class JCS_Logo : MonoBehaviour

private float mDelayTimer = 0.0f;

private bool mCycleThrough = false;

/* Setter & Getter */

public string NextLevel { get { return this.mNextLevel; } set { this.mNextLevel = value; } }
Expand All @@ -56,22 +54,10 @@ private void Start()

private void Update()
{
var gm = JCS_GameManager.instance;

gm.GAME_PAUSE = true;

mDelayTimer += JCS_Time.DeltaTime(mDeltaTimeType);

if (mDelayTime < mDelayTimer)
{
mCycleThrough = true;
}

if (mCycleThrough)
{
gm.GAME_PAUSE = false;
JCS_SceneManager.instance.LoadScene(mNextLevel);
}
}
}
}
7 changes: 7 additions & 0 deletions Assets/JCSUnity/Scripts/Managers/JCS_PauseManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public class JCS_PauseManager : JCS_Manager<JCS_PauseManager>
#if UNITY_EDITOR
[Separator("Helper Variables (JCS_PauseManager)")]

[Tooltip("See curren time scale.")]
[SerializeField]
[ReadOnly]
private float mTimeScale = 1.0f;

[Tooltip("Test this module?")]
[SerializeField]
private bool mTestWithKey = false;
Expand Down Expand Up @@ -111,6 +116,8 @@ private void Awake()
private void Update()
{
#if UNITY_EDITOR
mTimeScale = Time.timeScale;

TestPauseGame();
#endif

Expand Down
7 changes: 0 additions & 7 deletions Assets/JCSUnity/Scripts/Managers/JCS_SceneManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ public class JCS_SceneManager : JCS_Manager<JCS_SceneManager>

[Separator("Runtime Variables (JCS_SceneManager)")]

[Tooltip("Pause the game while the scene start to load.")]
[SerializeField]
private bool mPauseGameWhileLoadingScene = true;

[Header("- Screen")]

[Tooltip("Do this scene using the specific setting.")]
Expand Down Expand Up @@ -377,9 +373,6 @@ public void LoadScene(string sceneName, float fadeInTime, Color screenColor, boo

// start check to switch scene or not
mSwitchSceneEffect = true;

// Pause the game depends on setting...
JCS_GameManager.instance.GAME_PAUSE = mPauseGameWhileLoadingScene;
}

/// <summary>
Expand Down
Loading

0 comments on commit d35e761

Please sign in to comment.