Initial Commit
This commit is contained in:
48
Assets/Scripts/UnityXR/HandPresence.cs
Normal file
48
Assets/Scripts/UnityXR/HandPresence.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR;
|
||||
|
||||
namespace UnityXR
|
||||
{
|
||||
public class HandPresence : MonoBehaviour
|
||||
{
|
||||
private InputDevice _targetDevice;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
List<InputDevice> devices = new List<InputDevice>();
|
||||
InputDeviceCharacteristics rightControllerCharacteristics =
|
||||
InputDeviceCharacteristics.Right | InputDeviceCharacteristics.Controller;
|
||||
|
||||
if (devices.Count > 0)
|
||||
{
|
||||
_targetDevice = devices[0];
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
;
|
||||
if (_targetDevice.TryGetFeatureValue(CommonUsages.primaryButton, out bool primaryButtonValue) &&
|
||||
primaryButtonValue)
|
||||
{
|
||||
Debug.Log("Pressing primary button");
|
||||
}
|
||||
|
||||
|
||||
if (_targetDevice.TryGetFeatureValue(CommonUsages.trigger, out float triggerValue) && triggerValue > 0.1f)
|
||||
{
|
||||
Debug.Log("Trigger pressed " + triggerValue);
|
||||
}
|
||||
|
||||
|
||||
if (_targetDevice.TryGetFeatureValue(CommonUsages.primary2DAxis, out Vector2 primary2DAxisValue) &&
|
||||
primary2DAxisValue != Vector2.zero)
|
||||
{
|
||||
Debug.Log("primary2DAxis pressed " + triggerValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UnityXR/HandPresence.cs.meta
Normal file
11
Assets/Scripts/UnityXR/HandPresence.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df6b462fef11acb4fb7d56a91c73b4b5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
19
Assets/Scripts/UnityXR/TeleportWorldArea.cs
Normal file
19
Assets/Scripts/UnityXR/TeleportWorldArea.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR.Interaction.Toolkit;
|
||||
|
||||
namespace UnityXR
|
||||
{
|
||||
public class TeleportWorldArea : TeleportationArea
|
||||
{
|
||||
// Override the teleport request to use the world rotation and not our gameObject's transform
|
||||
protected override bool GenerateTeleportRequest(XRBaseInteractor interactor, RaycastHit raycastHit,
|
||||
ref TeleportRequest teleportRequest)
|
||||
{
|
||||
teleportRequest.destinationPosition = raycastHit.point;
|
||||
teleportRequest.destinationUpVector = Vector3.up; // use the area transform for data.
|
||||
teleportRequest.destinationForwardVector = Vector3.forward;
|
||||
teleportRequest.destinationRotation = Quaternion.identity;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UnityXR/TeleportWorldArea.cs.meta
Normal file
11
Assets/Scripts/UnityXR/TeleportWorldArea.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9bc374ab13b4e224384b965358d295cb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user