rabidus-test/Assets/CalibratePlayerCenter.cs

29 lines
573 B
C#
Raw Normal View History

2023-09-04 12:48:24 +03:00
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);
}
}