Felix Boucher 8adc563d47 make transition fool proof
problème :
Il y avait plusieurs manières de faire planter le loading screen en appuyant sur des boutons

changements:
- turn off buttons when loading screen is active
- turn on buttons when loading screen is not active
- add event aggregator class to project and migrate every event to it
- fix bugs and regressions
2023-10-09 22:21:06 -04:00

33 lines
910 B
C#

using GatherAndDefend.Events;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class GoToScene : MonoBehaviour
{
[SerializeField]
private bool _useLoadingScreen = true;
[SerializeField][Scene]
private string _loadingScreenScene;
[SerializeField][Scene]
private string _sceneToLoad;
[SerializeField]
private int _levelToLoad;
public void Execute()
{
if (_useLoadingScreen)
{
PlayerPrefs.SetString(LoadingManager.SceneToLoad, _sceneToLoad);
PlayerPrefs.SetInt(LoadingManager.LevelToLoad, _levelToLoad);
SceneManager.LoadScene(_loadingScreenScene, LoadSceneMode.Additive);
}
else
{
SceneManager.LoadScene(_sceneToLoad);
}
EventAggregator.Instance.GetEvent<ExitingLevelEvent>().Invoke();
}
}