浏览代码

Added option to FullScreenFadeAction to perform fade based on scaled/unscaled game time

/main
Thomas ICHÉ 4 年前
当前提交
c6ecd08b
共有 3 个文件被更改,包括 29 次插入6 次删除
  1. 4
      CHANGELOG.md
  2. 4
      Runtime/LevelScripting/Actions/FullScreenFadeAction.cs
  3. 27
      Runtime/Managers/Implementations/FullScreenFadeManager.cs

4
CHANGELOG.md


## 2019.3.7
#### Added
- Added option to FullScreenFadeAction to perform fade based on scaled/unscaled game time
#### Fixed
* Fixed Take Screenshot Action : Bad Filename + Added Tooltips

4
Runtime/LevelScripting/Actions/FullScreenFadeAction.cs


{
public FullScreenFadeManager.FadeMode Fading = FullScreenFadeManager.FadeMode.ToBlack;
public float Duration = 2.0f;
public FullScreenFadeManager.FadeTimingMode fadeTimingMode = FullScreenFadeManager.FadeTimingMode.UnscaledGameTime;
Manager.Get<FullScreenFadeManager>().Fade(Duration, Fading, OnComplete, instigator);
Manager.Get<FullScreenFadeManager>().Fade(Duration, Fading, fadeTimingMode, OnComplete, instigator);
}
}

27
Runtime/Managers/Implementations/FullScreenFadeManager.cs


ToBlack = 1
}
public enum FadeTimingMode
{
UnscaledGameTime,
GameTime,
}
public void Fade(float duration, FadeMode mode, Callable[] OnComplete, GameObject instigator = null)
public void Fade(float duration, FadeMode mode, FadeTimingMode timingMode, Callable[] OnComplete, GameObject instigator = null)
{
if (m_Coroutine != null)
{

switch (mode)
{
case FadeMode.ToBlack:
m_Coroutine = StartCoroutine(FadeCoroutine(duration, 1.0f, 1.0f, OnComplete, instigator));
m_Coroutine = StartCoroutine(FadeCoroutine(duration, 1.0f, 1.0f, timingMode, OnComplete, instigator));
m_Coroutine = StartCoroutine(FadeCoroutine(duration, 0.0f, -1.0f, OnComplete, instigator));
m_Coroutine = StartCoroutine(FadeCoroutine(duration, 0.0f, -1.0f, timingMode, OnComplete, instigator));
break;
default: throw new NotImplementedException();
}

IEnumerator FadeCoroutine(float duration, float target, float sign, Callable[] OnComplete, GameObject instigator)
IEnumerator FadeCoroutine(float duration, float target, float sign, FadeTimingMode timingMode, Callable[] OnComplete, GameObject instigator)
{
FullScreenFadePlane.gameObject.SetActive(true);
Color c = FullScreenFadePlane.color;

float t;
switch (timingMode)
{
case FadeTimingMode.GameTime:
t = Time.deltaTime;
break;
default:
case FadeTimingMode.UnscaledGameTime:
t = Time.unscaledDeltaTime;
break;
}
c.a += sign * Time.unscaledDeltaTime / duration;
c.a += sign * t / duration;
FullScreenFadePlane.color = c;
yield return new WaitForEndOfFrame();
}

正在加载...
取消
保存