feat(Cycle):实现循环提前检测,修复交互提示消失,按键绑定的事件在重启的时候没能正确,触发循环的提前检测有错误
This commit is contained in:
@@ -3,6 +3,7 @@ using Script.Gameplay.Interface;
|
||||
using System;
|
||||
using Core;
|
||||
using Script.Gameplay.Input;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
namespace Script.Gameplay.Player
|
||||
{
|
||||
@@ -46,16 +47,19 @@ namespace Script.Gameplay.Player
|
||||
Debug.LogWarning("FirstPersonRaycaster not found! Please assign or add it to the player.");
|
||||
|
||||
var input = InputManager.Instance.Input;
|
||||
input.Player.Interact.performed += ctx =>
|
||||
{
|
||||
if(CurrentTarget == null) return;
|
||||
if (!CurrentTarget.IsEnableInteract) return;
|
||||
CurrentTarget.Interact(this.gameObject);
|
||||
};
|
||||
|
||||
input.Player.Interact.performed += OnInteractOnperformed;
|
||||
|
||||
ControllerLocator.Instance.Register(this);
|
||||
}
|
||||
|
||||
private void OnInteractOnperformed(InputAction.CallbackContext ctx)
|
||||
{
|
||||
if (CurrentTarget == null) return;
|
||||
if (!CurrentTarget.IsEnableInteract) return;
|
||||
CurrentTarget.Interact(this.gameObject);
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
DetectInteractable();
|
||||
@@ -81,6 +85,14 @@ namespace Script.Gameplay.Player
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
ControllerLocator.Instance.Unregister<PlayerInteractorController>(this);
|
||||
|
||||
var input = InputManager.Instance.Input;
|
||||
input.Player.Interact.performed -= OnInteractOnperformed;
|
||||
}
|
||||
|
||||
void OnDrawGizmos()
|
||||
{
|
||||
// 交由 FirstPersonRaycaster 绘制射线
|
||||
|
||||
Reference in New Issue
Block a user