75 lines
1.8 KiB
C#
75 lines
1.8 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.XR;
|
|
|
|
public class DebugPanel : MonoBehaviour
|
|
{
|
|
public static DebugPanel Ins { get; private set; }
|
|
public GameObject Content;
|
|
|
|
private InputDevice leftHandDevice;
|
|
private InputDevice rightHandDevice;
|
|
private bool click = false;
|
|
private bool swithShow = false;
|
|
private int cd = 0;
|
|
|
|
public void Awake()
|
|
{
|
|
Ins = this;
|
|
click = false;
|
|
swithShow = false;
|
|
Content.SetActive(false);
|
|
}
|
|
|
|
public void Start()
|
|
{
|
|
#if !UNITY_EDITOR
|
|
leftHandDevice = InputDevices.GetDeviceAtXRNode(XRNode.LeftHand);
|
|
rightHandDevice = InputDevices.GetDeviceAtXRNode(XRNode.RightHand);
|
|
#endif
|
|
}
|
|
|
|
public void Update()
|
|
{
|
|
// 呼出debug
|
|
if (leftHandDevice != null && rightHandDevice != null)
|
|
{
|
|
if (cd > 0)
|
|
{
|
|
cd--;
|
|
return;
|
|
}
|
|
bool leftValue;
|
|
leftHandDevice.TryGetFeatureValue(CommonUsages.secondaryButton, out leftValue);
|
|
bool rightValue;
|
|
rightHandDevice.TryGetFeatureValue(CommonUsages.secondaryButton, out rightValue);
|
|
if (!click)
|
|
{
|
|
if (leftValue && rightValue)
|
|
{
|
|
swithShow = !swithShow;
|
|
click = true;
|
|
Content.SetActive(swithShow);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!leftValue && !rightValue)
|
|
{
|
|
click = false;
|
|
cd = 60;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
// M打开debug
|
|
if (Input.GetKeyDown(KeyCode.M))
|
|
{
|
|
swithShow = !swithShow;
|
|
Content.SetActive(swithShow);
|
|
}
|
|
}
|
|
}
|