Files
Shopping_UnityVR/Assets/02_Scripts/UI/ItemInfoHud.cs

44 lines
1006 B
C#

using UnityEngine;
using VRShopping.Items;
namespace VRShopping.UI
{
public class ItemInfoHud : MonoBehaviour
{
public static ItemInfoHud Instance { get; private set; }
[SerializeField] private ItemInfoPanel _leftPanel;
[SerializeField] private ItemInfoPanel _rightPanel;
private void Awake()
{
if (Instance != null && Instance != this)
{
Destroy(gameObject);
return;
}
Instance = this;
}
private void OnDestroy()
{
if (Instance == this) Instance = null;
}
public void Show(Handedness hand, ItemData data)
{
GetPanel(hand)?.Show(data);
}
public void Hide(Handedness hand)
{
GetPanel(hand)?.Hide();
}
private ItemInfoPanel GetPanel(Handedness hand)
{
return hand == Handedness.Left ? _leftPanel : _rightPanel;
}
}
}