Files
Genesis_Unity/Assets/02_Scripts/Interactions/InteractableSit.cs
sharedacc520k 7e19e4f248 2026-04-03 인트로 타임라인, 카메라 Rig 오작동 수정, 하이라이트 투과설정 수정
해야할 것 : 버리기(dynamicObjects에 버리기),아이템 다 사용했을때 없애기
2026-04-03 05:17:44 +09:00

86 lines
2.2 KiB
C#

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<HighlightEffect>();
if (_highlightEffect == null)
{
_highlightEffect = _interactionObject.AddComponent<HighlightEffect>();
}
}
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;
}
}
}