浏览代码

Fixed bug when player landed in multiple LocationExits at once

/main
Ciro Continisio 3 年前
当前提交
c5d56d4c
共有 1 个文件被更改,包括 18 次插入13 次删除
  1. 31
      UOP1_Project/Assets/Scripts/SceneManagement/SceneLoader.cs

31
UOP1_Project/Assets/Scripts/SceneManagement/SceneLoader.cs


private SceneInstance _gameplayManagerSceneInstance = new SceneInstance();
private float _fadeDuration = .5f;
private bool _isLoading = false; //To prevent a new loading request while already loading a new scene
private void OnEnable()
{

/// </summary>
private void LoadLocation(GameSceneSO locationToLoad, bool showLoadingScreen, bool fadeScreen)
{
//Prevent a double-loading, for situations where the player falls in two Exit colliders in one frame
if (_isLoading)
return;
_isLoading = true;
//In case we are coming from the main menu, we need to load the Gameplay manager scene first
if (_gameplayManagerSceneInstance.Scene == null

/// </summary>
private void LoadMenu(GameSceneSO menuToLoad, bool showLoadingScreen, bool fadeScreen)
{
//Prevent a double-loading, for situations where the player falls in two Exit colliders in one frame
if (_isLoading)
return;
_isLoading = true;
//In case we are coming from a Location back to the main menu, we need to get rid of the persistent Gameplay manager scene
if (_gameplayManagerSceneInstance.Scene != null

{
//Save loaded scenes (to be unloaded at next load request)
_currentlyLoadedScene = _sceneToLoad;
SetActiveScene();
Scene s = obj.Result.Scene;
SceneManager.SetActiveScene(s);
LightProbes.TetrahedralizeAsync();
_isLoading = false;
{
}
}
/// <summary>
/// This function is called when all the scenes have been loaded, to finalise loading and activate the main scene, and rebuild LightProbes as tetrahedrons.
/// </summary>
private void SetActiveScene()
{
Scene s = ((SceneInstance)_loadingOperationHandle.Result).Scene;
SceneManager.SetActiveScene(s);
LightProbes.TetrahedralizeAsync();
_fadeRequestChannel.FadeIn(_fadeDuration);
_fadeRequestChannel.FadeIn(_fadeDuration);
StartGameplay();
}

正在加载...
取消
保存