fix(peipei): UF_spriteIn 从 Yarn 变量解析 EyeTarget
切换 UF 模式后 CurrentTarget 可能为空,回退读取 $currentEyeTarget。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user