可能的性能优化
This commit is contained in:
@@ -46,19 +46,19 @@ namespace OCES.Audio
|
||||
/// <summary>
|
||||
/// 淡出分支:fire-and-forget,由调用方 StartCoroutine
|
||||
/// </summary>
|
||||
internal IEnumerator FadeOutBranch(ContainerPlayHandle outgoingHandle, float outgoingVolume, float fadeOutOffset, float fadeOutTime)
|
||||
internal IEnumerator FadeOutBranch(ContainerPlayHandle outgoingHandle, float outgoingVolume, ITransitionConfig transition)
|
||||
{
|
||||
if (outgoingHandle == null) yield break;
|
||||
|
||||
if (fadeOutOffset > 0f)
|
||||
if (transition?.FadeOutOffset > 0f)
|
||||
{
|
||||
Debug.Log($"Waiting for {fadeOutOffset} to fade out.");
|
||||
yield return new WaitForSeconds(fadeOutOffset);
|
||||
Debug.Log($"Waiting for {transition.FadeOutOffset} to fade out.");
|
||||
yield return new WaitForSeconds(transition.FadeOutOffset);
|
||||
}
|
||||
|
||||
if (fadeOutTime > 0f )
|
||||
if (transition?.FadeOutTime > 0f )
|
||||
yield return this.m_coroutineHost.StartCoroutine(
|
||||
FadeOut(outgoingHandle, outgoingVolume, fadeOutTime));
|
||||
FadeOut(outgoingHandle, outgoingVolume, transition.FadeOutTime));
|
||||
else
|
||||
StopHandle(outgoingHandle);
|
||||
}
|
||||
@@ -67,12 +67,12 @@ namespace OCES.Audio
|
||||
/// 淡入分支:等待 FadeInOffset 后启动新音乐并淡入。
|
||||
/// 主协程 yield return 此分支,以便 DoTransition 在新音乐就绪后才结束。
|
||||
/// </summary>
|
||||
internal IEnumerator FadeInBranch(uint newContainerId, float fadeInOffset, float fadeInTime, Action onContainerStarted = null)
|
||||
internal IEnumerator FadeInBranch(uint newContainerId, ITransitionConfig transition, Action onContainerStarted = null)
|
||||
{
|
||||
if (fadeInOffset > 0f)
|
||||
if (transition?.FadeOutOffset > 0f)
|
||||
{
|
||||
Debug.Log($"Waiting {fadeInOffset} to fade in.");
|
||||
yield return new WaitForSeconds(fadeInOffset);
|
||||
Debug.Log($"Waiting {transition.FadeInOffset} to fade in.");
|
||||
yield return new WaitForSeconds(transition.FadeInOffset);
|
||||
}
|
||||
|
||||
if (newContainerId == 0)
|
||||
@@ -82,13 +82,13 @@ namespace OCES.Audio
|
||||
yield break;
|
||||
}
|
||||
|
||||
float startVolume = fadeInTime > 0f ? 0f : 1f;
|
||||
float startVolume = transition?.FadeOutOffset > 0f ? 0f : 1f;
|
||||
StartNew(newContainerId, startVolume);
|
||||
|
||||
if (fadeInTime > 0f )
|
||||
if (transition?.FadeOutOffset > 0f)
|
||||
{
|
||||
yield return this.m_coroutineHost.StartCoroutine(
|
||||
FadeIn(CurrentHandle, fadeInTime));
|
||||
FadeIn(CurrentHandle, transition.FadeInTime));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user