浏览代码

Deleted while loop

Deleted while loop, changed _onFadeComplete to BoolEventChannel
/main
Wiecio 4 年前
当前提交
6208f362
共有 3 个文件被更改,包括 11 次插入28 次删除
  1. 3
      UOP1_Project/Assets/ScriptableObjects/Events/UI/FadeCompleteEvent.asset
  2. 32
      UOP1_Project/Assets/Scripts/SceneManagement/SceneLoader.cs
  3. 4
      UOP1_Project/Assets/Scripts/UI/FadeManager.cs

3
UOP1_Project/Assets/ScriptableObjects/Events/UI/FadeCompleteEvent.asset


m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 7fafac715ff920c4383fed91a38a351e, type: 3}
m_Script: {fileID: 11500000, guid: 3177d113f09ae42448cde1e1a5067d4f, type: 3}
description:

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


{
[SerializeField] private GameSceneSO _gameplayScene = default;
[SerializeField] private InputReader _inputReader = default;
[SerializeField] private VoidEventChannelSO _fadeOutComplete = default;
[SerializeField] private BoolEventChannelSO _fadeOutComplete = default;
[SerializeField] private float _fadeDuration = 1f;
[Header("Load Events")]

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

_loadMenu.OnLoadingRequested += LoadMenu;
_fadeOutComplete.OnEventRaised += FadeComplete;
}
private void OnDisable()

_fadeOutComplete.OnEventRaised -= FadeComplete;
}
/// <summary>

}
_inputReader.DisableAllInput();
StartCoroutine(HandleFadeRoutine(true, _fadeDuration));
}
_fadeRequest.Fade(true, _fadeDuration);
private void FadeComplete()
{
_isFadeComplete = true;
/// Request Fade from FadeManager and waits until fade is finished
/// If fade in was performed (closing a scene), calls LoadNewScenes()
/// If fade out was performed (opening a scene), enables gameplay input
/// When fade is complete, continue loading or enable gameplay
private IEnumerator HandleFadeRoutine(bool fadeIn, float duration)
private void FadeComplete(bool fadeIn)
Debug.Log("Started fading");
_isFadeComplete = false;
_fadeOutComplete.OnEventRaised += FadeComplete;
_fadeRequest.Fade(fadeIn, duration);
while(_isFadeComplete == false)
{
yield return null;
}
_fadeOutComplete.OnEventRaised -= FadeComplete;
Debug.Log("Finished Fading");
_inputReader.EnableGameplayInput();
_inputReader.EnableGameplayInput();
}
/// <summary>

_toggleLoadingScreen.RaiseEvent(false);
}
StartCoroutine(HandleFadeRoutine(false, _fadeDuration));
_fadeRequest.Fade(false, _fadeDuration);
}
/// <summary>

4
UOP1_Project/Assets/Scripts/UI/FadeManager.cs


{
[SerializeField] private FadeChannelSO _fadeChannelSO;
[SerializeField] private Image _imageComponent;
[SerializeField] private VoidEventChannelSO _onFadeComplete;
[SerializeField] private BoolEventChannelSO _onFadeComplete;
private bool _isCurrentlyFading = false;

_imageComponent.color = endColor; //Force to end result
_isCurrentlyFading = false;
_onFadeComplete.RaiseEvent();
_onFadeComplete.RaiseEvent(fadeIn);
}
/// <summary>

正在加载...
取消
保存