using HighlightPlus; using UnityEngine; using UnityEngine.AI; public class InteractableSit : MonoBehaviour, IInteractable { private bool interactionOnOff = false; [SerializeField] private GameObject _interactionObject; private HighlightProfile _highlightProfile; private HighlightEffect _highlightEffect; private void Awake() { _highlightEffect = _interactionObject.GetComponent(); if (_highlightEffect == null) { _highlightEffect = _interactionObject.AddComponent(); } } private void Start() { _highlightProfile = GameManager.Instance.InteractionHighlightProfile; _highlightEffect.ProfileLoad(_highlightProfile); _highlightEffect.highlighted = false; } private void Update() { if (interactionOnOff) { //메인카메라를 기준으로 좌표 변환 Vector3 pos = Camera.main.WorldToScreenPoint(transform.position + Vector3.up * 0.5f); //변환된 좌표로 InteractionBox 이동 GameManager.Instance.InGameUI.Interaction.UpdateSitBoxPos(pos); } } public void InteractOpen() { if (interactionOnOff == true) return; interactionOnOff = true; ActiveEffect(true); GameManager.Instance.InGameUI.Interaction.OnOffSitBox(true); } public void InteractClose() { if (interactionOnOff == false) return; interactionOnOff = false; ActiveEffect(false); GameManager.Instance.InGameUI.Interaction.OnOffSitBox(false); } public void InteractExec(PlayerCharacterController player) { player.PointSitAction(this.transform); GameManager.Instance.InGameUI.InteractionVisible(false); ActiveEffect(false); } public void InteractEnd(PlayerCharacterController player) { GameManager.Instance.InGameUI.InteractionVisible(true); if (interactionOnOff) { ActiveEffect(true); } } public void ActiveEffect(bool isOn) { if(isOn) { _highlightEffect.highlighted = true; } else { _highlightEffect.highlighted = false; } } }