Camera.main

Posted lakeone

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Camera.main相关的知识,希望对你有一定的参考价值。

在Unity项目的C#代码中可以看到Camera.main.transform.position、Camera.main.transform.eulerAngles、Camera.main.transform.rotation等代码。

那么Camera.main是什么意思呢?

Camera类

A Camera is a device through which the player views the world.

Camera类包含以下静态变量:

allCameras Returns all enabled cameras in the scene.
allCamerasCount The number of cameras in the current scene.
current The camera we are currently rendering with, for low-level render control only (Read Only).
main The first enabled camera tagged "MainCamera" (Read Only).
onPostRender Event that is fired after any camera finishes rendering.
onPreCull Event that is fired before any camera starts culling.
onPreRender Event that is fired before any camera starts rendering.

Description of Camera.main 

The first enabled camera tagged "MainCamera" (Read Only).

Returns null if there is no such camera in the scene.

以上是关于Camera.main的主要内容,如果未能解决你的问题,请参考以下文章

unity为啥坐标转换都要用camera.main?

Camera.main.WorldToScreenPoint注意事项

血条遮挡问题详解

unity 点积的使用 转化为角度

unity ui坐标系转换

Input.GetAxis("Mouse ScrollWheel")控制摄像机视野缩放