장보기 프로젝트
This commit is contained in:
43
Assets/02_Scripts/UI/ItemInfoHud.cs
Normal file
43
Assets/02_Scripts/UI/ItemInfoHud.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user