diff --git a/Assets/Scripts/MiniGame/Peipei/UF/UFSystem.cs b/Assets/Scripts/MiniGame/Peipei/UF/UFSystem.cs index 8deca61b9..8b4082d0a 100644 --- a/Assets/Scripts/MiniGame/Peipei/UF/UFSystem.cs +++ b/Assets/Scripts/MiniGame/Peipei/UF/UFSystem.cs @@ -62,13 +62,36 @@ public class UFSystem : MonoBehaviour eyeSystem?.SetUnifiedUfWeights(0f, 0f, 0f); } + private EyeTarget ResolveSpriteTarget() + { + if (eyeSystem == null) + { + return null; + } + + if (eyeSystem.CurrentTarget != null) + { + return eyeSystem.CurrentTarget; + } + + if (YarnVariableStorage.Instance != null + && YarnVariableStorage.Instance.TryGetValue("$currentEyeTarget", out string targetName) + && !string.IsNullOrEmpty(targetName)) + { + return eyeSystem.FindEyeTargetByName(targetName); + } + + return null; + } + [YarnCommand("UF_spriteIn")] public IEnumerator UF_spriteIn(float duration = 1.5f) { - if (eyeSystem.CurrentTarget != null) + var target = ResolveSpriteTarget(); + if (target != null) { AudioManager.Instance.PlaySfx("event:/ActionFB/color_imagine"); - eyeSystem.CurrentTarget.ImageIn(duration); + target.ImageIn(duration); } yield return new WaitForSeconds(duration); @@ -77,10 +100,11 @@ public class UFSystem : MonoBehaviour [YarnCommand("UF_spriteOut")] public IEnumerator UF_spriteOut(float duration = 1.5f) { - if (eyeSystem.CurrentTarget != null) + var target = ResolveSpriteTarget(); + if (target != null) { AudioManager.Instance.PlaySfx("event:/ActionFB/color_imagine"); - eyeSystem.CurrentTarget.ImageOut(duration); + target.ImageOut(duration); } yield return new WaitForSeconds(duration);