feat(Gaze): 实现注视相关提示
This commit is contained in:
58
Assets/Script/Gameplay/UI/PlayerGazeReminder.cs
Normal file
58
Assets/Script/Gameplay/UI/PlayerGazeReminder.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using Core;
|
||||
using UnityEngine;
|
||||
using Script.Gameplay.Player;
|
||||
using TMPro;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class PlayerGazeReminder : UIBase
|
||||
{
|
||||
[SerializeField] private TMP_Text reminderFirstText;
|
||||
[SerializeField] private TMP_Text reminderSecondText;
|
||||
private PlayerInteractorController playerInteractorController;
|
||||
private PlayerConnectController playerConnectController;
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
reminderFirstText.text = "";
|
||||
reminderSecondText.text = "";
|
||||
ControllerLocator.Instance.TryGetWait<PlayerInteractorController>(OnGetInteractorController);
|
||||
ControllerLocator.Instance.TryGetWait<PlayerConnectController>(OnGetConnectController);
|
||||
}
|
||||
|
||||
private void OnGetInteractorController(PlayerInteractorController controller)
|
||||
{
|
||||
playerInteractorController = controller;
|
||||
playerInteractorController.OnGazeEnter += HandleInteractGazeEnter;
|
||||
playerInteractorController.OnGazeExit += HandleInteractGazeExit;
|
||||
}
|
||||
|
||||
private void HandleInteractGazeEnter(GameObject obj)
|
||||
{
|
||||
reminderFirstText.text = "Press [F] to interact";
|
||||
}
|
||||
|
||||
private void HandleInteractGazeExit(GameObject obj)
|
||||
{
|
||||
reminderFirstText.text = "";
|
||||
}
|
||||
|
||||
private void OnGetConnectController(PlayerConnectController controller)
|
||||
{
|
||||
playerConnectController = controller;
|
||||
playerConnectController.OnGazeEnter += HandleConnectGazeEnter;
|
||||
playerConnectController.OnGazeExit += HandleConnectGazeExit;
|
||||
}
|
||||
|
||||
private void HandleConnectGazeEnter(GameObject obj)
|
||||
{
|
||||
reminderFirstText.text = "Connectable";
|
||||
}
|
||||
|
||||
private void HandleConnectGazeExit(GameObject obj)
|
||||
{
|
||||
reminderFirstText.text = "";
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user