LoadAsync + fix button play
This commit is contained in:
parent
9ae93651f1
commit
e5f6f9fa54
@ -456,8 +456,8 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: -287.83038, y: -33.478283}
|
||||
m_SizeDelta: {x: 140.4212, y: 256.4461}
|
||||
m_AnchoredPosition: {x: -273.40057, y: -40.693207}
|
||||
m_SizeDelta: {x: 127.3032, y: 299.7355}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &585937283
|
||||
MonoBehaviour:
|
||||
|
@ -91,10 +91,32 @@ public class GameSession : MonoBehaviour,IResettable
|
||||
|
||||
public void GoToGameScene()
|
||||
{
|
||||
SceneManager.LoadScene("GameScene", LoadSceneMode.Single);
|
||||
StartCoroutine(LoadGameSceneAsync());
|
||||
}
|
||||
|
||||
private IEnumerator LoadGameSceneAsync()
|
||||
{
|
||||
AsyncOperation asyncLoad = SceneManager.LoadSceneAsync("GameScene", LoadSceneMode.Single);
|
||||
asyncLoad.allowSceneActivation = false;
|
||||
|
||||
while (!asyncLoad.isDone)
|
||||
{
|
||||
// Indiquer la progression de chargement (0 à 0.9)
|
||||
float progress = Mathf.Clamp01(asyncLoad.progress / 0.9f);
|
||||
Debug.Log($"Loading progress: {progress * 100}%");
|
||||
|
||||
// Activer la scène lorsqu'elle est prête
|
||||
if (asyncLoad.progress >= 0.9f)
|
||||
{
|
||||
asyncLoad.allowSceneActivation = true;
|
||||
}
|
||||
|
||||
yield return null;
|
||||
}
|
||||
ResetToDefault();
|
||||
}
|
||||
|
||||
|
||||
public void GoToMainMenu()
|
||||
{
|
||||
SceneManager.LoadScene("MainMenu", LoadSceneMode.Single);
|
||||
@ -104,6 +126,7 @@ public class GameSession : MonoBehaviour,IResettable
|
||||
public void ResetToDefault()
|
||||
{
|
||||
PauseSession(false);
|
||||
if(currentPlayer !=null)
|
||||
currentPlayer.ResetToDefault();
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user