Files
valheim/Assets/Wave/Essence/InputModule/5.5.0-r.10/Scripts/GUI/HandPointerProvider.cs
2025-07-04 14:16:14 +08:00

91 lines
2.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// "Wave SDK
// © 2020 HTC Corporation. All Rights Reserved.
//
// Unless otherwise required by copyright law and practice,
// upon the execution of HTC SDK license agreement,
// HTC grants you access to and use of the Wave SDK(s).
// You shall fully comply with all of HTCs SDK license agreement terms and
// conditions signed by you and all SDK and API requirements,
// specifications, and documentation provided by HTC to You."
using System.Collections.Generic;
using UnityEngine;
using Wave.Native;
using Wave.Essence.Hand;
namespace Wave.Essence.InputModule
{
public class HandPointerProvider
{
private const string LOG_TAG = "Wave.Essence.InputModule.HandPointerProvider";
private void DEBUG(string msg)
{
if (Log.EnableDebugLog)
Log.d(LOG_TAG, msg, true);
}
private class PointerStorage
{
public HandManager.HandType Hand { get; set; }
public GameObject Pointer { get; set; }
public PointerStorage(HandManager.HandType type, GameObject pointer)
{
Hand = type;
Pointer = pointer;
}
}
private List<PointerStorage> m_HandPointers = new List<PointerStorage>();
private readonly HandManager.HandType[] s_HandTypes = new HandManager.HandType[] {
HandManager.HandType.Right,
HandManager.HandType.Left
};
private static HandPointerProvider instance = null;
public static HandPointerProvider Instance
{
get
{
if (instance == null)
instance = new HandPointerProvider();
return instance;
}
}
private HandPointerProvider()
{
for (int i = 0; i < s_HandTypes.Length; i++)
m_HandPointers.Add(new PointerStorage(s_HandTypes[i], null));
}
public void SetHandPointer(HandManager.HandType hand, GameObject pointer)
{
DEBUG("SetHandPointer() " + hand + ", pointer: " + (pointer != null ? pointer.name : "null"));
for (int i = 0; i < s_HandTypes.Length; i++)
{
if (s_HandTypes[i] == hand)
{
m_HandPointers[i].Pointer = pointer;
break;
}
}
}
public GameObject GetHandPointer(HandManager.HandType hand)
{
int index = 0;
for (int i = 0; i < s_HandTypes.Length; i++)
{
if (s_HandTypes[i] == hand)
{
index = i;
break;
}
}
return m_HandPointers[index].Pointer;
}
}
}