Files
PrinceOfGlory/Assets/Scripts/MyHandReset/PXR_PicoHandPinchGesture.cs
Sora丶kong 2f0862b382 修复报错
2026-03-03 11:32:30 +08:00

65 lines
1.4 KiB
C#

#if PICO_SDK || PXR_SDK
using Unity.XR.PXR;
using UnityEngine;
public class PXR_PicoHandPinchGesture : PicoHandDeviceDoEvent
{
public HandType handType;
private HandAimState aimState = new HandAimState();
private bool aimRayTouched = false;
private bool pinch = false;
public bool AimRayTouched { get => aimRayTouched; set => aimRayTouched = value; }
public float PinchStrength { get; private set; }
public bool Pinch
{
get => pinch;
set
{
if (pinch != value)
{
if (value)
{
GripOn();
}
else
{
GripOff();
}
}
pinch = value;
}
}
void Update()
{
UpdateAimState();
}
private void UpdateAimState()
{
if (PXR_HandTracking.GetAimState(handType, ref aimState))
{
PinchStrength = aimState.touchStrengthRay;
AimRayTouched = (aimState.aimStatus & HandAimStatus.AimRayTouched) != 0;
if (PinchStrength > 0.6f || AimRayTouched)
{
Pinch = true;
}
else
{
Pinch = false;
}
}
}
}
#else
using UnityEngine;
public class PXR_PicoHandPinchGesture : PicoHandDeviceDoEvent
{
}
#endif