refactor(peipei): UF 效果改由后处理 Volume 驱动
将 UF 想象/记忆/Ascii 状态从 unified shader weight 迁移至 Volume weight tween。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -25,7 +25,7 @@ public class UFSystem : MonoBehaviour
|
||||
[Header("Global UF Cover")]
|
||||
[SerializeField] private Volume FullAscillVolume;
|
||||
|
||||
[Header("Legacy Volumes (unused; kept for scene refs)")]
|
||||
[Header("Target Post-Processing Volumes")]
|
||||
[SerializeField] private Volume imageAscillVolume;
|
||||
[SerializeField] private Volume imageVolume;
|
||||
[SerializeField] private Volume finalVolume;
|
||||
@@ -44,14 +44,22 @@ public class UFSystem : MonoBehaviour
|
||||
{
|
||||
FixSystemCenter.SystemDic.Register(this);
|
||||
eyeSystem = FindObjectOfType<EyeSystem>();
|
||||
ResetLegacyTargetVolumes();
|
||||
ClearUnifiedUfSpriteWeights();
|
||||
}
|
||||
|
||||
private void ResetLegacyTargetVolumes()
|
||||
public void TweenWeight(Volume postProcessingVolume, float targetWeight, float duration)
|
||||
{
|
||||
if (imageAscillVolume != null) imageAscillVolume.weight = 0f;
|
||||
if (imageVolume != null) imageVolume.weight = 0f;
|
||||
if (finalVolume != null) finalVolume.weight = 0f;
|
||||
if (postProcessingVolume == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
DOTween.To(() => postProcessingVolume.weight, x => postProcessingVolume.weight = x, targetWeight, duration);
|
||||
}
|
||||
|
||||
private void ClearUnifiedUfSpriteWeights()
|
||||
{
|
||||
eyeSystem?.SetUnifiedUfWeights(0f, 0f, 0f);
|
||||
}
|
||||
|
||||
[YarnCommand("UF_spriteIn")]
|
||||
@@ -120,54 +128,67 @@ public class UFSystem : MonoBehaviour
|
||||
public IEnumerator UF_ImaginationEffectIn(float duration = 1.5f)
|
||||
{
|
||||
AudioManager.Instance.PlaySfx("event:/ActionFB/color_imagine");
|
||||
eyeSystem?.TweenUnifiedUfWeights(0f, 1f, 0f, duration);
|
||||
yield return new WaitForSeconds(duration);
|
||||
ClearUnifiedUfSpriteWeights();
|
||||
TweenWeight(imageVolume, 1f, duration);
|
||||
yield return new WaitForSeconds(0f);
|
||||
}
|
||||
|
||||
[YarnCommand("UF_ImaginationEffectOut")]
|
||||
public IEnumerator UF_ImaginationEffectOut(float duration = 1.5f)
|
||||
{
|
||||
eyeSystem?.TweenUnifiedUfWeights(0f, 0f, 0f, duration);
|
||||
TweenWeight(imageVolume, 0f, duration);
|
||||
AudioManager.Instance.PlaySfx("event:/ActionFB/color_imagine");
|
||||
yield return new WaitForSeconds(duration);
|
||||
yield return new WaitForSeconds(0f);
|
||||
}
|
||||
|
||||
[YarnCommand("UF_MemoryEffectIn")]
|
||||
public IEnumerator UF_MemoryEffectIn(float duration = 1.5f)
|
||||
{
|
||||
AudioManager.Instance.PlaySfx("event:/ActionFB/color_imagine");
|
||||
eyeSystem?.TweenUnifiedUfWeights(0f, 0f, 1f, duration);
|
||||
yield return new WaitForSeconds(duration);
|
||||
ClearUnifiedUfSpriteWeights();
|
||||
TweenWeight(finalVolume, 1f, duration);
|
||||
yield return new WaitForSeconds(0f);
|
||||
}
|
||||
|
||||
[YarnCommand("UF_MemoryEffectOut")]
|
||||
public IEnumerator UF_MemoryEffectOut(float duration = 1.5f)
|
||||
{
|
||||
eyeSystem?.TweenUnifiedUfWeights(0f, 0f, 0f, duration);
|
||||
TweenWeight(finalVolume, 0f, duration);
|
||||
AudioManager.Instance.PlaySfx("event:/ActionFB/color_imagine");
|
||||
yield return new WaitForSeconds(duration);
|
||||
yield return new WaitForSeconds(0f);
|
||||
}
|
||||
|
||||
[YarnCommand("UF_EyeTargetAscillIn")]
|
||||
public IEnumerator UF_EyeTargetAscillIn(float duration = 1.5f)
|
||||
{
|
||||
AudioManager.Instance.PlaySfx("event:/ActionFB/color_imagine");
|
||||
eyeSystem?.TweenUnifiedUfWeights(1f, 0f, 0f, duration);
|
||||
yield return new WaitForSeconds(duration);
|
||||
ClearUnifiedUfSpriteWeights();
|
||||
TweenWeight(imageAscillVolume, 1f, duration);
|
||||
yield return new WaitForSeconds(0f);
|
||||
}
|
||||
|
||||
[YarnCommand("UF_EyeTargetAscillOut")]
|
||||
public IEnumerator UF_EyeTargetAscillOut(float duration = 1.5f)
|
||||
{
|
||||
eyeSystem?.TweenUnifiedUfWeights(0f, 0f, 0f, duration);
|
||||
TweenWeight(imageAscillVolume, 0f, duration);
|
||||
AudioManager.Instance.PlaySfx("event:/ActionFB/color_imagine");
|
||||
yield return new WaitForSeconds(duration);
|
||||
yield return new WaitForSeconds(0f);
|
||||
}
|
||||
|
||||
[YarnCommand("UF_SetBorkenValue")]
|
||||
public void UF_Borken(int value)
|
||||
{
|
||||
if (FullAscillVolume != null && FullAscillVolume.profile.TryGet(out ascii))
|
||||
if (FullAscillVolume == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!FullAscillVolume.gameObject.activeInHierarchy)
|
||||
{
|
||||
FullAscillVolume.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
if (FullAscillVolume.profile.TryGet(out ascii))
|
||||
{
|
||||
ascii.m_Depth.value = value;
|
||||
ascii.m_Ascii.value = Color.red;
|
||||
@@ -189,12 +210,23 @@ public class UFSystem : MonoBehaviour
|
||||
[YarnCommand("UF_fightEffect")]
|
||||
public void UF_fightEffect()
|
||||
{
|
||||
ClearUnifiedUfSpriteWeights();
|
||||
scaleTween = DOTween.To(() => 0f, t =>
|
||||
{
|
||||
float dreamWeight = Mathf.Lerp(0f, 1f, t);
|
||||
float asciiWeight = Mathf.Lerp(0f, 1f, t);
|
||||
float memoryWeight = Mathf.Lerp(1f, 0f, t);
|
||||
eyeSystem?.SetUnifiedUfWeights(asciiWeight, dreamWeight, memoryWeight);
|
||||
if (imageVolume != null)
|
||||
{
|
||||
imageVolume.weight = Mathf.Lerp(0f, 1f, t);
|
||||
}
|
||||
|
||||
if (imageAscillVolume != null)
|
||||
{
|
||||
imageAscillVolume.weight = Mathf.Lerp(0f, 1f, t);
|
||||
}
|
||||
|
||||
if (finalVolume != null)
|
||||
{
|
||||
finalVolume.weight = Mathf.Lerp(1f, 0f, t);
|
||||
}
|
||||
}, 1f, 1f)
|
||||
.SetEase(Ease.InOutSine)
|
||||
.SetLoops(-1, LoopType.Yoyo);
|
||||
@@ -216,10 +248,12 @@ public class UFSystem : MonoBehaviour
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
StartCoroutine(UF_spriteIn(0.5f));
|
||||
StartCoroutine(UF_ImaginationEffectIn(0.5f));
|
||||
eyeSystem.Targets[index].ImageIn(0.5f);
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
StartCoroutine(UF_ImaginationEffectOut(0.5f));
|
||||
StartCoroutine(UF_MemoryEffectIn(0.5f));
|
||||
yield return new WaitForSeconds(1f);
|
||||
eyeSystem.Targets[index].ImageOut(0.5f);
|
||||
StartCoroutine(UF_MemoryEffectOut(0.5f));
|
||||
index++;
|
||||
if (index >= eyeSystem.Targets.Count - 2)
|
||||
@@ -231,13 +265,27 @@ public class UFSystem : MonoBehaviour
|
||||
|
||||
public void OpenUFView()
|
||||
{
|
||||
ClearUnifiedUfSpriteWeights();
|
||||
|
||||
if (FullAscillVolume != null && !FullAscillVolume.gameObject.activeInHierarchy)
|
||||
{
|
||||
FullAscillVolume.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
ResetLegacyTargetVolumes();
|
||||
eyeSystem?.SetUnifiedUfWeights(1f, 0f, 0f);
|
||||
if (imageAscillVolume != null)
|
||||
{
|
||||
imageAscillVolume.weight = 1f;
|
||||
}
|
||||
|
||||
if (imageVolume != null)
|
||||
{
|
||||
imageVolume.weight = 0f;
|
||||
}
|
||||
|
||||
if (finalVolume != null)
|
||||
{
|
||||
finalVolume.weight = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
public void CloseUFView()
|
||||
@@ -247,8 +295,22 @@ public class UFSystem : MonoBehaviour
|
||||
FullAscillVolume.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
ResetLegacyTargetVolumes();
|
||||
eyeSystem?.SetUnifiedUfWeights(0f, 0f, 0f);
|
||||
if (imageAscillVolume != null)
|
||||
{
|
||||
imageAscillVolume.weight = 1f;
|
||||
}
|
||||
|
||||
if (imageVolume != null)
|
||||
{
|
||||
imageVolume.weight = 0f;
|
||||
}
|
||||
|
||||
if (finalVolume != null)
|
||||
{
|
||||
finalVolume.weight = 0f;
|
||||
}
|
||||
|
||||
ClearUnifiedUfSpriteWeights();
|
||||
}
|
||||
|
||||
public void OpenCover()
|
||||
@@ -281,16 +343,24 @@ public class UFSystem : MonoBehaviour
|
||||
}
|
||||
|
||||
AudioManager.Instance.PlaySfx("event:/ActionFB/color_imagine");
|
||||
ClearUnifiedUfSpriteWeights();
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case UFState.UF:
|
||||
eyeSystem?.TweenUnifiedUfWeights(1f, 0f, 0f, duration);
|
||||
TweenWeight(imageAscillVolume, 1f, duration);
|
||||
TweenWeight(imageVolume, 0f, duration);
|
||||
TweenWeight(finalVolume, 0f, duration);
|
||||
break;
|
||||
case UFState.imagination:
|
||||
eyeSystem?.TweenUnifiedUfWeights(0f, 1f, 0f, duration);
|
||||
TweenWeight(imageAscillVolume, 0f, duration);
|
||||
TweenWeight(imageVolume, 1f, duration);
|
||||
TweenWeight(finalVolume, 0f, duration);
|
||||
break;
|
||||
case UFState.memory:
|
||||
eyeSystem?.TweenUnifiedUfWeights(0f, 0f, 1f, duration);
|
||||
TweenWeight(imageAscillVolume, 0f, duration);
|
||||
TweenWeight(imageVolume, 0f, duration);
|
||||
TweenWeight(finalVolume, 1f, duration);
|
||||
break;
|
||||
default:
|
||||
Debug.LogError($"Unhandled state: {state}");
|
||||
|
||||
Reference in New Issue
Block a user