fix: guard eye module input initialization
This commit is contained in:
@@ -65,6 +65,23 @@ namespace AibisDream
|
||||
Init();
|
||||
}
|
||||
|
||||
private bool EnsureMouseFollowAndZoom()
|
||||
{
|
||||
if (mouseFollowAndZoom != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
mouseFollowAndZoom = FindObjectOfType<MouseFollowAndZoom>(true);
|
||||
if (mouseFollowAndZoom == null)
|
||||
{
|
||||
Debug.LogError("[EyeSystem] MouseFollowAndZoom 未找到,无法进入视觉模块。", this);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
FixSystemCenter.SystemDic.Register(this);
|
||||
@@ -81,6 +98,8 @@ namespace AibisDream
|
||||
{
|
||||
cameraManager.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
EnsureMouseFollowAndZoom();
|
||||
}
|
||||
|
||||
private void LoadData(EyeData eyedata)
|
||||
@@ -90,6 +109,11 @@ namespace AibisDream
|
||||
|
||||
public void OnEnter()
|
||||
{
|
||||
if (!EnsureMouseFollowAndZoom())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 先激活 ViewCamera
|
||||
if (cameraManager != null)
|
||||
{
|
||||
@@ -127,7 +151,11 @@ namespace AibisDream
|
||||
eyeStateEffect?.CleanupEffect(CurrentTarget);
|
||||
}
|
||||
|
||||
mouseFollowAndZoom.SetIsActive(false);
|
||||
if (EnsureMouseFollowAndZoom())
|
||||
{
|
||||
mouseFollowAndZoom.SetIsActive(false);
|
||||
}
|
||||
|
||||
currentTarget = null;
|
||||
// 先关闭 EyeView
|
||||
CloseEyeView();
|
||||
@@ -144,7 +172,7 @@ namespace AibisDream
|
||||
{
|
||||
SetEyeColorState(_eyeData.currentState);
|
||||
|
||||
mouseFollowAndZoom = FindObjectOfType<MouseFollowAndZoom>();
|
||||
EnsureMouseFollowAndZoom();
|
||||
}
|
||||
|
||||
public EyeTarget FindEyeTargetByName(string name)
|
||||
@@ -166,6 +194,11 @@ namespace AibisDream
|
||||
[YarnCommand("set_Eyetarget")]
|
||||
public IEnumerator SetTargetCoroutine(string targetName, bool startDialogue = true)
|
||||
{
|
||||
if (!EnsureMouseFollowAndZoom())
|
||||
{
|
||||
yield break;
|
||||
}
|
||||
|
||||
mouseFollowAndZoom.SetIsLock(true);
|
||||
EyeTarget target = FindEyeTargetByName(targetName);
|
||||
if (target == null)
|
||||
@@ -209,6 +242,11 @@ namespace AibisDream
|
||||
[YarnCommand("Set_MouseMovementLockState")]
|
||||
public void SetMouseMovementLockState(bool isActive)
|
||||
{
|
||||
if (!EnsureMouseFollowAndZoom())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
mouseFollowAndZoom.SetIsLock(isActive);
|
||||
}
|
||||
|
||||
@@ -503,4 +541,4 @@ namespace AibisDream
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user