feat(GazeReminder): 实现更多提示
This commit is contained in:
@@ -43,11 +43,11 @@ namespace Script.Gameplay.Player
|
||||
{
|
||||
if (currentTarget != null)
|
||||
{
|
||||
OnGazeEnter?.Invoke((currentTarget as MonoBehaviour)?.gameObject);
|
||||
OnGazeEnterConnectable?.Invoke((currentTarget as MonoBehaviour)?.gameObject);
|
||||
}
|
||||
if (previousTarget != null)
|
||||
{
|
||||
OnGazeExit?.Invoke((previousTarget as MonoBehaviour)?.gameObject);
|
||||
OnGazeExitConnectable?.Invoke((previousTarget as MonoBehaviour)?.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -60,8 +60,8 @@ namespace Script.Gameplay.Player
|
||||
private IConnectable inputTarget;
|
||||
public event Action<IConnectable> OnSetPointA;
|
||||
public event Action<IConnectable> OnSetPointB;
|
||||
public event Action<GameObject> OnGazeEnter;
|
||||
public event Action<GameObject> OnGazeExit;
|
||||
public event Action<GameObject> OnGazeEnterConnectable;
|
||||
public event Action<GameObject> OnGazeExitConnectable;
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@ using UnityEngine;
|
||||
using Script.Gameplay.Interface;
|
||||
using Script.Gameplay.Input;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Script.Gameplay.Global;
|
||||
|
||||
namespace Script.Gameplay.Player
|
||||
@@ -12,11 +13,34 @@ namespace Script.Gameplay.Player
|
||||
[SerializeField] private FirstPersonRaycaster raycaster; // 新增:第一人称射线检测器
|
||||
public bool IsEnableEditing = true; // 是否启用编辑功能
|
||||
private bool isEditing = false; // 当前是否处于编辑状态
|
||||
public event Action<GameObject> OnGazeEnterEditableComponent;
|
||||
public event Action<GameObject> OnGazeExitEditableComponent;
|
||||
public event Action<GameObject> OnBeginEditTarget;
|
||||
public event Action<GameObject> OnEndEditTarget;
|
||||
|
||||
private GameObject previousTarget; // 上一次注视的对象(用于注视进入/离开事件)
|
||||
private GameObject currentTarget; // 射线命中的当前可编辑对象(用于按键交互)
|
||||
private GameObject previousGazedTarget; // 上一次注视的对象(用于注视进入/离开事件)
|
||||
|
||||
public GameObject CurrentTarget
|
||||
{
|
||||
get => currentTarget;
|
||||
set
|
||||
{
|
||||
previousTarget = currentTarget;
|
||||
currentTarget = value;
|
||||
if (previousTarget != currentTarget)
|
||||
{
|
||||
if (currentTarget != null)
|
||||
{
|
||||
OnGazeEnterEditableComponent?.Invoke((currentTarget)?.gameObject);
|
||||
}
|
||||
if (previousTarget != null)
|
||||
{
|
||||
OnGazeExitEditableComponent?.Invoke((previousTarget)?.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private InputManager inputManager;
|
||||
|
||||
@@ -53,23 +77,7 @@ namespace Script.Gameplay.Player
|
||||
hitEditable = lookAtObj;
|
||||
}
|
||||
}
|
||||
currentTarget = hitEditable;
|
||||
|
||||
// // 如果命中对象与之前注视的不一样,触发进入/离开事件
|
||||
// if (hitEditable != previousGazedTarget)
|
||||
// {
|
||||
// if (previousGazedTarget != null)
|
||||
// {
|
||||
// // previousGazedTarget.OnGazeExit(this);
|
||||
// }
|
||||
//
|
||||
// if (hitEditable != null)
|
||||
// {
|
||||
// // hitEditable.OnGazeEnter(this);
|
||||
// }
|
||||
//
|
||||
// previousGazedTarget = hitEditable;
|
||||
// }
|
||||
CurrentTarget = hitEditable;
|
||||
}
|
||||
|
||||
private void EditTarget()
|
||||
@@ -77,7 +85,7 @@ namespace Script.Gameplay.Player
|
||||
if (isEditing)
|
||||
{
|
||||
isEditing = false;
|
||||
OnEndEditTarget?.Invoke(currentTarget);
|
||||
OnEndEditTarget?.Invoke(CurrentTarget);
|
||||
inputManager.SetCursorState(false, CursorLockMode.Locked);
|
||||
inputManager.SetInputForLook(true);
|
||||
inputManager.SetInputForMove(true);
|
||||
@@ -88,10 +96,10 @@ namespace Script.Gameplay.Player
|
||||
}
|
||||
else
|
||||
{
|
||||
if (currentTarget == null) return;
|
||||
if (CurrentTarget == null) return;
|
||||
if (!IsEnableEditing) return;
|
||||
isEditing = true;
|
||||
OnBeginEditTarget?.Invoke(currentTarget);
|
||||
OnBeginEditTarget?.Invoke(CurrentTarget);
|
||||
inputManager.SetCursorState(true, CursorLockMode.Confined);
|
||||
inputManager.SetInputForLook(false);
|
||||
inputManager.SetInputForMove(false);
|
||||
|
||||
Reference in New Issue
Block a user