UnityAPI手册-2019.4官网版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
Camera.fieldOfView
# [Camera](https://docs.unity3d.com/cn/2019.4/ScriptReference/Camera.html).fieldOfView public float **fieldOfView** ; ## 描述 摄像机的视野(以度为单位)。 这是垂直视野;水平 视野随视口宽高比的变化而改变,有关更多信息,请参阅 [VerticalToHorizontalFieldOfView](https://docs.unity3d.com/cn/2019.4/ScriptReference/Camera.VerticalToHorizontalFieldOfView.html)。 如果是正交摄像机,则忽略视野(请参阅 [orthographic](https://docs.unity3d.com/cn/2019.4/ScriptReference/Camera-orthographic.html))。 某些 VR SDK 具有用于 VR 摄像机的固定视野值。使用这些 SDK 启用 VR 时,该属性将始终返回来自 SDK 的值。如果您尝试设置该属性,则会在记录中看到一条警告,并且该值会被忽略。 如果对 [projectionMatrix](https://docs.unity3d.com/cn/2019.4/ScriptReference/Camera-projectionMatrix.html) 进行更改,摄像机将不再根据其 [fieldOfView](https://docs.unity3d.com/cn/2019.4/ScriptReference/Camera-fieldOfView.html) 更新渲染。在调用 [ResetProjectionMatrix](https://docs.unity3d.com/cn/2019.4/ScriptReference/Camera.ResetProjectionMatrix.html) 之前,该设置持续有效。 如果对 [projectionMatrix](https://docs.unity3d.com/cn/2019.4/ScriptReference/Camera-projectionMatrix.html) 进行更改,摄像机将不再根据其 [fieldOfView](https://docs.unity3d.com/cn/2019.4/ScriptReference/Camera-fieldOfView.html) 更新渲染。在调用 [ResetProjectionMatrix](https://docs.unity3d.com/cn/2019.4/ScriptReference/Camera.ResetProjectionMatrix.html) 之前,该设置持续有效。 另请参阅:[camera component](https://docs.unity3d.com/cn/2019.4/Manual/class-Camera.html)。 ``` //Attach this script to an empty GameObject. //This script creates a Slider that allows you to manipulate the Camera's field of view. Place GameObjects in the Scene to show the full effect. using UnityEngine; public class CameraFieldOfViewExample : MonoBehaviour { //This is the field of view that the Camera has float m_FieldOfView; void Start() { //Start the Camera field of view at 60 m_FieldOfView = 60.0f; } void Update() { //Update the camera's field of view to be the variable returning from the Slider Camera.main.fieldOfView = m_FieldOfView; } void OnGUI() { //Set up the maximum and minimum values the Slider can return (you can change these) float max, min; max = 150.0f; min = 20.0f; //This Slider changes the field of view of the Camera between the minimum and maximum values m_FieldOfView = GUI.HorizontalSlider(new Rect(20, 20, 100, 40), m_FieldOfView, min, max); } } ```
da
2022年5月24日 10:19
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码