добавил немного функционала
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public class InputHandler : MonoBehaviour, IGameComponent
|
||||
{
|
||||
private Controls inputSystem;
|
||||
private Transform cameraTransform;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
inputSystem = new Controls();
|
||||
cameraTransform = transform;
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
GameSystem.Instance.AddGameComponent(this);
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
inputSystem.Enable();
|
||||
InputSystem.EnableDevice(UnityEngine.InputSystem.AttitudeSensor.current);
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
InputSystem.DisableDevice(UnityEngine.InputSystem.AttitudeSensor.current);
|
||||
inputSystem.Disable();
|
||||
}
|
||||
|
||||
public void OnUpdate()
|
||||
{
|
||||
var phoneRotation = inputSystem
|
||||
.Rotation
|
||||
.Gyroscope
|
||||
.ReadValue<Quaternion>();
|
||||
|
||||
cameraTransform.rotation = phoneRotation;
|
||||
cameraTransform.Rotate(0, 0, 180, Space.Self);
|
||||
cameraTransform.Rotate(90, 180, 0, Space.World);
|
||||
}
|
||||
|
||||
public void OnFixedUpdate() { }
|
||||
public void OnLateUpdate() { }
|
||||
|
||||
public void OnDestroy()
|
||||
{
|
||||
GameSystem.Instance.RemoveGameComponent(this);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user