Files
cppk-ar/Assets/Scripts/InputHandler.cs
T
2022-11-12 15:15:01 +05:00

38 lines
804 B
C#

using System.Linq;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class InputHandler : MonoBehaviour, IGameComponent
{
private Transform cameraTransform;
void Awake()
{
cameraTransform = transform;
}
void Start()
{
GameSystem.Instance.AddGameComponent(this);
Input.gyro.enabled = true;
}
public void OnUpdate()
{
var phoneRotation = Input.gyro.attitude;
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);
}
}