摄像机的类型
摄像机有两种类型:“Perspective”(放射观察角度)和“Orthographic”(垂直观察角度)。
视图修改摄像机类型
在摄像机的Inspector视图中的“Projection”下拉菜单中可以修改摄像机类型。
脚本动态修改摄像机类型
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class E5_01 : MonoBehaviour {
private Camera camera = new Camera();
void Start () {
camera = gameObject.GetComponent<Camera>();
}
void OnGUI()
{
if(GUILayout.Button("放射观察",GUILayout.Height(50)))
{
camera.orthographic = false;
}
if (GUILayout.Button("垂直观察", GUILayout.Height(50)))
{
camera.orthographic = true;
}
}
}