浏览代码

Added bool parameter to LoadEventChannelSO

Now you can specify if you want to fade screen during loading
/main
Wiecio 4 年前
当前提交
13e36ce1
共有 4 个文件被更改,包括 19 次插入10 次删除
  1. 6
      UOP1_Project/Assets/Scripts/Events/ScriptableObjects/LoadEventChannelSO.cs
  2. 2
      UOP1_Project/Assets/Scripts/SaveSystem/SaveSystem.cs
  3. 3
      UOP1_Project/Assets/Scripts/SceneManagement/LocationExit.cs
  4. 18
      UOP1_Project/Assets/Scripts/SceneManagement/SceneLoader.cs

6
UOP1_Project/Assets/Scripts/Events/ScriptableObjects/LoadEventChannelSO.cs


[CreateAssetMenu(menuName = "Events/Load Event Channel")]
public class LoadEventChannelSO : EventChannelBaseSO
{
public UnityAction<GameSceneSO[], bool> OnLoadingRequested;
public UnityAction<GameSceneSO[], bool, bool> OnLoadingRequested;
public void RaiseEvent(GameSceneSO[] locationsToLoad, bool showLoadingScreen = false)
public void RaiseEvent(GameSceneSO[] locationsToLoad, bool showLoadingScreen = false, bool fadeScreen = false)
OnLoadingRequested.Invoke(locationsToLoad, showLoadingScreen);
OnLoadingRequested.Invoke(locationsToLoad, showLoadingScreen, fadeScreen);
}
else
{

2
UOP1_Project/Assets/Scripts/SaveSystem/SaveSystem.cs


_loadLocation.OnLoadingRequested -= CacheLoadLocations;
}
private void CacheLoadLocations(GameSceneSO[] locationsToLoad, bool showLoadingScreen)
private void CacheLoadLocations(GameSceneSO[] locationsToLoad, bool showLoadingScreen, bool fadeScreen)
{
LocationSO locationSo = locationsToLoad[0] as LocationSO;
if (locationSo)

3
UOP1_Project/Assets/Scripts/SceneManagement/LocationExit.cs


[Header("Loading settings")]
[SerializeField] private GameSceneSO[] _locationsToLoad = default;
[SerializeField] private bool _showLoadScreen = default;
[SerializeField] private bool _fadeScreen = true;
[SerializeField] private PathAnchor _pathTaken = default;
[SerializeField] private PathSO _exitPath = default;

if (other.CompareTag("Player"))
{
UpdatePathTaken();
_locationExitLoadChannel.RaiseEvent(_locationsToLoad, _showLoadScreen);
_locationExitLoadChannel.RaiseEvent(_locationsToLoad, _showLoadScreen, _fadeScreen);
}
}

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


private GameSceneSO[] _scenesToLoad;
private GameSceneSO[] _currentlyLoadedScenes = new GameSceneSO[] { };
private bool _showLoadingScreen;
private bool _fadeScreen;
private SceneInstance _gameplayManagerSceneInstance = new SceneInstance();

/// <summary>
/// This function loads the location scenes passed as array parameter
/// </summary>
private void LoadLocation(GameSceneSO[] locationsToLoad, bool showLoadingScreen)
private void LoadLocation(GameSceneSO[] locationsToLoad, bool showLoadingScreen, bool fadeScreen)
_fadeScreen = fadeScreen;
//In case we are coming from the main menu, we need to load the persistent Gameplay manager scene first
if (_gameplayManagerSceneInstance.Scene == null

/// <summary>
/// Prepares to load the main menu scene, first removing the Gameplay scene in case the game is coming back from gameplay to menus.
/// </summary>
private void LoadMenu(GameSceneSO[] menusToLoad, bool showLoadingScreen)
private void LoadMenu(GameSceneSO[] menusToLoad, bool showLoadingScreen, bool fadeScreen)
_fadeScreen = fadeScreen;
//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

}
_inputReader.DisableAllInput();
_fadeRequest.Fade(true, _fadeDuration);
if(_fadeScreen)
_fadeRequest.Fade(true, _fadeDuration);
else
LoadNewScenes();
}
/// <summary>

{
_toggleLoadingScreen.RaiseEvent(false);
}
_fadeRequest.Fade(false, _fadeDuration);
if(_fadeScreen)
_fadeRequest.Fade(false, _fadeDuration);
else
_inputReader.EnableGameplayInput();
}
/// <summary>

正在加载...
取消
保存