using UnityEngine;
public class ModelComponent : MonoBehaviour
{
[SerializeField] private Camera m_Camera;
void Update()
{
if (Input.GetMouseButton(0))
{
float speed = 2.5f;
float OffsetX = Input.GetAxis("Mouse X");
float OffsetY = Input.GetAxis("Mouse Y");
transform.Rotate(new Vector3(OffsetY, -OffsetX, 0) * speed, Space.World);
}
if (Input.GetAxis ("Mouse ScrollWheel") < 0)
{
if (m_Camera == null) return;
if (m_Camera.fieldOfView <= 80)
m_Camera.fieldOfView += 2;
}
if (Input.GetAxis ("Mouse ScrollWheel") > 0)
{
if (m_Camera == null) return;
if (m_Camera.fieldOfView >= 20)
m_Camera.fieldOfView -= 2;
}
}
}
|