Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using VRTK;
- using UnityEngine.XR;
- using Oculus.Avatar;
- using Photon.Pun;
- public class AvatarCustomDriverOpenVR : OvrAvatarDriver
- {
- void Awake()
- {
- }
- private void Start()
- {
- #if UNITY_ANDROID
- try
- {
- GameObject reference = VRTK_DeviceFinder.GetControllerLeftHand();
- if (reference) {
- reference.GetComponent<VRTK_Pointer>().enabled = false;
- reference.GetComponent<VRTK_UIPointer>().enabled = false;
- if(reference.GetComponent<InputSwitcherUI>()!=null) reference.GetComponent<InputSwitcherUI>().enabled = false;
- }
- }
- catch (Exception e) {
- Debug.LogException(e);
- }
- #endif
- }
- float voiceAmplitude = 0.0f;
- ControllerPose GetControllerPose()
- {
- ovrAvatarButton buttons = 0;
- ovrAvatarTouch touches = 0;
- return new ControllerPose
- {
- buttons = buttons,
- touches = touches,
- joystickPosition = Vector3.zero,
- indexTrigger = 0,
- handTrigger = 0,
- isActive = true,
- };
- }
- private void CalculateCurrentPose()
- {
- Vector3 headPos = UnityEngine.XR.InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.CenterEye);
- CurrentPose = new PoseFrame
- {
- voiceAmplitude = voiceAmplitude,
- headPosition = headPos,
- headRotation = UnityEngine.XR.InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.CenterEye),
- handLeftPosition = UnityEngine.XR.InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.LeftHand),
- handLeftRotation = UnityEngine.XR.InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.LeftHand),
- handRightPosition = UnityEngine.XR.InputTracking.GetLocalPosition(UnityEngine.XR.XRNode.RightHand),
- handRightRotation = UnityEngine.XR.InputTracking.GetLocalRotation(UnityEngine.XR.XRNode.RightHand),
- controllerLeftPose = GetControllerPose(),
- controllerRightPose = GetControllerPose(),
- };
- }
- public override void UpdateTransforms(IntPtr sdkAvatar)
- {
- CalculateCurrentPose();
- UpdateTransformsFromPose(sdkAvatar);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement