Camera 摄像机

Inherits from Behaviour

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

Camera是一个设备,玩家通过它看世界。

A screen space point is defined in pixels. The bottom-left of the screen is (0,0); the right-top  is (pixelWidth,pixelHeight). The z position is in world units from the camera.

屏幕空间点用像素定义,屏幕的左下为(0,0);右上是(PixelWidth,pixelHeight).Z的位置是以世界单位衡量的到相机的距离。

A viewport space point is normalized and relative to the camera. The bottom-left of the camera is  (0,0); the top-right is (1,1). The z position is in world units from the camera.

视口空间点是归一化的并相对于相机的。相机的左下为(0,0);右上是(1,1);Z的位置是以世界为单位衡量的到相机的距离。

A world space point is defined in global coordinates (eg. Transform.position).

世界空间点是以全局坐标定义的(例如:Transform.position)

Variables变量

  • fieldOfView
    The field of view of the camera in degrees.
          相机的视野,以度为单位。
  • nearClipPlane
    The near clipping plane distance.
          近裁剪面的距离。
  • farClipPlane
    The far clipping plane distance.
          远裁剪面的距离。
  • renderingPath
    Rendering path.
          渲染路径。
  • actualRenderingPath
    Actually used rendering path (Read Only).
          实际使用的渲染路径(只读)。
  • orthographicSize
    Camera's half-size when in orthographic mode.
          在正交模式下相机的一半尺寸。
  • orthographic
    Is the camera orthographic (true) or perspective (false)?
          相机是正交的(true),是透视的(false)?
  • depth
    Camera's depth in the camera rendering order.
          相机在渲染顺序上的深度。
  • aspect
    The aspect ratio (width divided by height).
          长宽比(宽度除以高度)。
  • cullingMask
    This is used to render parts of the scene selectively.
          这个用来选择性的渲染部分场景。
  • backgroundColor
    The color with which the screen will be cleared.
          屏幕将被清理为这个颜色。
  • rect
    Where on the screen is the camera rendered in normalized coordinates.
          相继被渲染到屏幕规范化坐标中的位置。
  • pixelRect
    Where on the screen is the camera rendered in pixel coordinates.
          相机被渲染到屏幕像素中的位置。
  • targetTexture
    Destination render texture (Unity Pro only).
       描述渲染纹理(仅Unity专业版)。
  • pixelWidth
    How wide is the camera in pixels (Read Only).
          相机有多宽,以像素单位(只读)。
  • pixelHeight
    How tall is the camera in pixels (Read Only).
          相机有多高,以像素单位(只读)。
  • cameraToWorldMatrix
    Matrix that transforms from camera space to world space (Read Only).
          从相机空间到世界空间的变换矩阵(只读)。
  • worldToCameraMatrix
    Matrix that transforms from world to camera space.
          从世界到相机空间的变换矩阵。
  • projectionMatrix
    Set a custom projection matrix.
          设置自定义的投影矩阵。
  • velocity
    Get the world-space speed of the camera (Read Only).
          获取世界空间中相机的速度(只读)。
  • clearFlags
    How the camera clears the background.
          相机如何清除背景。
  • layerCullDistances
    Per-layer culling distances.
          每层的消隐距离。
  • depthTextureMode
    How and if camera generates a depth texture.
          相机生成怎样的一个深度纹理。

Functions函数

  • ResetWorldToCameraMatrix
    Make the rendering position reflect the camera's position in the scene.
          在场景中让渲染位置反映相机的位置。
  • ResetProjectionMatrix
    Make the projection reflect normal camera's parameters.
          让投影反映正常的相机参数。
  • ResetAspect
    Revert the aspect ratio to the screen's aspect ratio.
          恢复长宽比为屏幕的长宽比。
  • WorldToScreenPoint
    Transforms position from world space into screen space.
          从世界空间到屏幕空间变换位置。
  • WorldToViewportPoint
    Transforms position from world space into viewport space.
          从世界空间到视窗空间的变换位置。
  • ViewportToWorldPoint
    Transforms position from viewport space into world space.
          从视窗空间到世界空间的变换位置。
  • ScreenToWorldPoint
    Transforms position from screen space into world space.
          从屏幕空间到世界空间的变化位置。
  • ScreenToViewportPoint
    Transforms position from screen space into viewport space.
          从屏幕空间到视窗空间的变换位置。
  • ViewportToScreenPoint
    Transforms position from viewport space into screen space.
          从视口空间到屏幕空间的变换位置。
  • ViewportPointToRay
    Returns a ray going from camera through a viewport point.
          返回从相机出发穿过视点的一个射线。
  • ScreenPointToRay
    Returns a ray going from camera through a screen point.
          返回一条射线从摄像机通过一个屏幕点。
  • Render
    Render the camera manually.
          手动渲染相机。
  • RenderWithShader
    Render the camera with shader replacement.
          用shader替代渲染相机。
  • SetReplacementShader
    Make the camera render with shader replacement.
          使相机渲染用shader替换。
  • ResetReplacementShader
    Remove shader replacement from camera.
          从相机上移除shader替换。
  • RenderToCubemap
    Render into a cubemap from this camera.
          从这个相机渲染到一个立方贴图。
  • CopyFrom
    Makes this camera's settings match other camera.
          使这个相机的设置与其他相机相同。

Messages Sent发送消息

  • OnPreCull
    OnPreCull is called before a camera culls the scene.
          OnPreCull在相机开始裁剪场景之前调用。
  • OnPreRender
    OnPreRender is called before a camera starts rendering the scene.
          OnPreRender在相机开始渲染场景之前调用。
  • OnPostRender
    OnPostRender is called after a camera has finished rendering the scene.
          OnPostRender 在相机渲染场景之后调用。
  • OnRenderImage
    OnRenderImage is called after all rendering is complete to render image
          OnRenderImage在所有渲染完成后被调用,来渲染图片的后期处理效果(仅限UnityPro)。
  • OnRenderObject
    OnRenderObject is called after camera has rendered the scene.
          OnRenderObject 被用来渲染你自己的物体,使用或者其他函数。
  • OnWillRenderObject
    OnWillRenderObject is called once for each camera if the object is visible.
          如果物体可见,每个相机都会调用OnWillRenderObject。

Class Functions类函数

  • main
    The first enabled camera tagged "MainCamera" (Read Only).
          第一个启用的被标记为“MainCanmera”的相机(只读)。
  • current
    The camera we are currently rendering with, for low-level render control only (Read Only).
          当前用于渲染的相机,只用于低级的渲染控制(只读)
  • allCameras
    Returns all enabled cameras in the scene.
          allCameras 所有相机

Inherited members继承成员Inherited Variables继承变量

  • enabled
    Enabled Behaviours are Updated, disabled Behaviours are not.
          启用行为被更新,禁用行为不更新。
  • transform
    The Transform attached to this GameObject (null if there is none attached).
          Transform附加到GameObject(游戏物体)(如无附加则为空)。
  • rigidbody
    The Rigidbody attached to this GameObject (null if there is none attached).
          Rigidbody附加到GameObject(游戏物体)(如无附加则为空)。
  • camera
    The Camera attached to this GameObject (null if there is none attached).
          Camera附加到GameObject(游戏物体)(如无附加则为空)。
  • light
    The Light attached to this GameObject (null if there is none attached).
          Light附加到GameObject(游戏物体)(如无附加则为空)。
  • animation
    The Animation attached to this GameObject (null if there is none attached).
          Animation附加到GameObject(游戏物体)(如无附加则为空)。
  • constantForce
    The ConstantForce attached to this GameObject (null if there is none attached).
          ConstantForce附加到GameObject(游戏物体)(如无附加则为空)。
  • renderer
    The Renderer attached to this GameObject (null if there is none attached).
          Renderer附加到GameObject(游戏物体)(如无附加则为空)。
  • audio
    The AudioSource attached to this GameObject (null if there is none attached).
          AudioSource附加到GameObject(游戏物体)(如无附加则为空)。
  • guiText
    The GUIText attached to this GameObject (null if there is none attached).
          GUIText附加到GameObject(游戏物体)(如无附加则为空)。
  • networkView
    The NetworkView attached to this GameObject (Read Only). (null if there is none attached)
          NetworkView附加到GameObject(游戏物体)(只读)(如无附加则为空)。
  • guiTexture
    The GUITexture attached to this GameObject (Read Only). (null if there is none attached)
          GUITexture附加到GameObject(游戏物体)(只读)(如无附加则为空)。
  • collider
    The Collider attached to this GameObject (null if there is none attached).
          Collider附加到GameObject(游戏物体)(如无附加则为空)。
  • hingeJoint
    The HingeJoint attached to this GameObject (null if there is none attached).
          HingeJoint附加到GameObject(游戏物体)(如无附加则为空)。
  • particleEmitter
    The ParticleEmitter attached to this GameObject (null if there is none attached).
          ParticleEmitter附加到GameObject(游戏物体)(如无附加则为空)。
  • gameObject
    The game object this component is attached to. A component is always attached to a game object.
          组件附加的游戏物体。一个组件总是被附加到一个游戏物体。
  • tag
    The tag of this game object.
          游戏物体的标签。
  • name
    The name of the object. //物体的名字
  • hideFlags
    Should the object be hidden, saved with the scene or modifiable by the user?
       物体是否被隐藏、保存在场景中或被用户修改?

Inherited Functions继承函数

  • GetComponent
    Returns the component of Type type if the game object has one attached, null if it doesn't.
          如果游戏物体有一个附加,则返回Type类型的组件,如果没有则为null。
  • GetComponent.<T>
  • GetComponent
    Returns the component with name type if the game object has one attached, null if it doesn't.
          如果游戏物体有一个附加,则返回名字类型组件,如果没有则为null。
  • GetComponentInChildren
    Returns the component of Type type in the GameObject or any of its children using depth first search.
    返回Type类型组件,在GameObject或它的任何子物体使用深度优先搜索,仅返回激活的组件。
  • GetComponentInChildren.<T>
  • GetComponentsInChildren
    Returns all components of Type type in the GameObject or any of its children.
          在GameObject或任何它的子物体,返回全部Type类型组件
  • GetComponentsInChildren.<T>
  • GetComponents
    Returns all components of Type type in the GameObject.
          在游戏物体返回全部Type类型组件。
  • GetComponents.<T>
  • CompareTag
    Is this game object tagged tag?
          游戏物体有被标记标签么?
  • SendMessageUpwards
    Calls the method named methodName on every MonoBehaviour in this game object and on every ancestor of the behaviour
          在游戏物体每一个MonoBehaviour和每一个behaviour的祖先上调用名为methodName的方法。
  • SendMessage
    Calls the method named methodName on every MonoBehaviour in this game object.
          在游戏物体每一个MonoBehaviour上调用名为methodName的方法。
  • BroadcastMessage
    Calls the method named methodName on every MonoBehaviour in this game object or any of its children.
          在游戏物体每一个MonoBehaviour和它的全部子物体上调用名为methodName的方法。
  • GetInstanceID
    Returns the instance id of the object.
       返回物体的实例ID
  • ToString
    Returns the name of the game object.
    返回游戏物体的名称。

Inherited Class Functions继承类函数

  • Destroy
    Removes a gameobject, component or asset.
       删除一个游戏物体、组件或资源
  • DestroyImmediate
    Destroys the object obj immediately. It is strongly recommended to use Destroy instead.
       立即销毁物体obj,强烈建议使用Destroy代替。
  • DontDestroyOnLoad
    Makes the object target not be destroyed automatically when loading a new scene.
       加载新场景的时候使目标物体不被自动销毁。
  • FindObjectOfType
    Returns the first active loaded object of Type type.
       返回Type类型第一个激活的加载的物体。
  • FindObjectsOfType
    Returns a list of all active loaded objects of Type type.
       返回Type类型的所有激活的加载的物体列表
  • Instantiate
    Clones the object original and returns the clone.
        克隆原始物体,并返回克隆的物体
,