2026-05-01 호버 버그 수정
This commit is contained in:
Binary file not shown.
54
Assets/02_Scripts/Interact/ItemHoverHighlight.cs
Normal file
54
Assets/02_Scripts/Interact/ItemHoverHighlight.cs
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.XR.Interaction.Toolkit;
|
||||||
|
using UnityEngine.XR.Interaction.Toolkit.Interactables;
|
||||||
|
using HighlightPlus;
|
||||||
|
|
||||||
|
namespace VRShopping.Interact
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 호버 중이고 선택되지 않은 상태에서만 HighlightPlus 외곽선 표시.
|
||||||
|
/// </summary>
|
||||||
|
[RequireComponent(typeof(XRBaseInteractable))]
|
||||||
|
[RequireComponent(typeof(HighlightEffect))]
|
||||||
|
public class ItemHoverHighlight : MonoBehaviour
|
||||||
|
{
|
||||||
|
private HighlightEffect _highlight;
|
||||||
|
private XRBaseInteractable _interactable;
|
||||||
|
|
||||||
|
private void Awake()
|
||||||
|
{
|
||||||
|
_interactable = GetComponent<XRBaseInteractable>();
|
||||||
|
if (_highlight == null) _highlight = GetComponent<HighlightEffect>();
|
||||||
|
_highlight.highlighted = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnEnable()
|
||||||
|
{
|
||||||
|
_interactable.hoverEntered.AddListener(OnHoverEntered);
|
||||||
|
_interactable.hoverExited.AddListener(OnHoverExited);
|
||||||
|
_interactable.selectEntered.AddListener(OnSelectEntered);
|
||||||
|
_interactable.selectExited.AddListener(OnSelectExited);
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDisable()
|
||||||
|
{
|
||||||
|
_interactable.hoverEntered.RemoveListener(OnHoverEntered);
|
||||||
|
_interactable.hoverExited.RemoveListener(OnHoverExited);
|
||||||
|
_interactable.selectEntered.RemoveListener(OnSelectEntered);
|
||||||
|
_interactable.selectExited.RemoveListener(OnSelectExited);
|
||||||
|
_highlight.highlighted = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnHoverEntered(HoverEnterEventArgs _) => Refresh();
|
||||||
|
private void OnHoverExited(HoverExitEventArgs _) => Refresh();
|
||||||
|
private void OnSelectEntered(SelectEnterEventArgs _) => Refresh();
|
||||||
|
private void OnSelectExited(SelectExitEventArgs _) => Refresh();
|
||||||
|
|
||||||
|
private void Refresh()
|
||||||
|
{
|
||||||
|
// 잡지 않은 상태로 호버 중일 때만 하이라이트
|
||||||
|
_highlight.highlighted = _interactable.isHovered && !_interactable.isSelected;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/02_Scripts/Interact/ItemHoverHighlight.cs.meta
Normal file
2
Assets/02_Scripts/Interact/ItemHoverHighlight.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 12303fdfb60bb8d409e58f95b5b13012
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user