EKsumic's Blog

let today = new Beginning();

Click the left button to use the catalog.

OR

[Unity]什么是Camera.main?

官方文档解释:

The primary Camera in the Scene. Returns null if there is no such camera in the Scene. This property uses FindGameObjectsWithTag internally and doesn't cache the result. It is advised to cache the return value of Camera.main if it is used multiple times per frame.

场景中的主摄影机。如果场景中没有此类摄影机,则返回null。此属性在内部使用FindGameObjectsWithTag,不缓存结果。如果每帧使用多次,建议缓存Camera.main的返回值。

 

官方描述:

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

 

根据官方描述,它会以寻找Tag的形式,找到第一个Tag名称为MainCamera的摄像机。

并且如果你有多个Tag为MainCamera的GameObject,它只会寻找第一个并且是Camera的Object,没有就返回null。

 

 

 

参考文档:

[1] Camera.main - 简书

[2] Unity官方文档 - Camera.main

This article was last edited at 2020-04-11 19:01:05

* *