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