feat(): 实现EditComponent的UI基础,引入TextMeshPro,添加了在Inside状态下不能互动物体的逻辑控制
This commit is contained in:
@@ -11,6 +11,7 @@ namespace Gameplay.Player
|
||||
[SerializeField] private LayerMask interactableLayer;
|
||||
[SerializeField] private Camera playerCamera;
|
||||
[SerializeField] private bool isDrawGizmos;
|
||||
[SerializeField] private bool isEnablePlayerInteraction = true; // 是否启用玩家交互功能
|
||||
|
||||
private IInteractable currentTarget; // 被射线命中的当前可交互对象(用于按键交互)
|
||||
private IInteractable previousGazedTarget; // 上一次注视的对象(用于注视进入/离开事件)
|
||||
@@ -38,6 +39,7 @@ namespace Gameplay.Player
|
||||
void DetectInteractable()
|
||||
{
|
||||
if (playerCamera == null) return;
|
||||
if (!isEnablePlayerInteraction) return;
|
||||
|
||||
Ray ray = new Ray(playerCamera.transform.position, playerCamera.transform.forward);
|
||||
if (Physics.Raycast(ray, out RaycastHit hit, interactRange, interactableLayer))
|
||||
@@ -76,6 +78,17 @@ namespace Gameplay.Player
|
||||
currentTarget = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetPlayerInteractionEnabled(bool isEnabled)
|
||||
{
|
||||
isEnablePlayerInteraction = isEnabled;
|
||||
if (!isEnabled && previousGazedTarget != null)
|
||||
{
|
||||
previousGazedTarget.OnGazeExit(this.gameObject);
|
||||
previousGazedTarget = null;
|
||||
currentTarget = null;
|
||||
}
|
||||
}
|
||||
|
||||
void OnDrawGizmos()
|
||||
{
|
||||
|
@@ -21,6 +21,7 @@ namespace Gameplay.Player
|
||||
private InputManager inputManager;
|
||||
private TimePauseManager timePauseManager;
|
||||
private WatchMode currentMode = WatchMode.Normal;
|
||||
private PlayerInteractorController playerInteractorController;
|
||||
|
||||
public WatchMode CurrentWatchMode
|
||||
{
|
||||
@@ -46,6 +47,7 @@ namespace Gameplay.Player
|
||||
{
|
||||
inputManager = InputManager.Instance;
|
||||
timePauseManager = TimePauseManager.Instance;
|
||||
playerInteractorController = GetComponent<PlayerInteractorController>();
|
||||
|
||||
var input = inputManager.Input;
|
||||
input.Player.SwitchWatchMode.performed += ctx =>
|
||||
@@ -73,6 +75,11 @@ namespace Gameplay.Player
|
||||
timePauseManager.SetPaused(false);
|
||||
}
|
||||
|
||||
if (playerInteractorController != null)
|
||||
{
|
||||
playerInteractorController.SetPlayerInteractionEnabled(true);
|
||||
}
|
||||
|
||||
break;
|
||||
case WatchMode.Inside:
|
||||
SetSeeLines(false);
|
||||
@@ -84,6 +91,11 @@ namespace Gameplay.Player
|
||||
timePauseManager.SetPaused(true);
|
||||
}
|
||||
|
||||
if (playerInteractorController != null)
|
||||
{
|
||||
playerInteractorController.SetPlayerInteractionEnabled(false);
|
||||
}
|
||||
|
||||
break;
|
||||
case WatchMode.Outside:
|
||||
SetSeeLines(true);
|
||||
@@ -95,6 +107,11 @@ namespace Gameplay.Player
|
||||
timePauseManager.SetPaused(false);
|
||||
}
|
||||
|
||||
if (playerInteractorController != null)
|
||||
{
|
||||
playerInteractorController.SetPlayerInteractionEnabled(true);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
|
Reference in New Issue
Block a user