29 lines
573 B
C#
29 lines
573 B
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.XR;
|
|
|
|
public class CalibratePlayerCenter : MonoBehaviour
|
|
{
|
|
void OnEnable()
|
|
{
|
|
#if UNITY_2019_3_OR_NEWER
|
|
InputDevices.deviceConnected += onDeviceChanged;
|
|
#endif
|
|
}
|
|
|
|
void OnDisable()
|
|
{
|
|
#if UNITY_2019_3_OR_NEWER
|
|
InputDevices.deviceConnected -= onDeviceChanged;
|
|
#endif
|
|
}
|
|
|
|
private void onDeviceChanged(InputDevice obj)
|
|
{
|
|
var result = obj.subsystem.TryRecenter();
|
|
Debug.Log("Recenter: " + result);
|
|
}
|
|
}
|