Camera.RenderToCubemap 渲染到立方图

function RenderToCubemap (cubemap : Cubemap, faceMask : int = 63) : bool


Render into a cubemap from this camera.


This is mostly useful in the editor for "baking" static cubemaps of your scene. See wizard example below.


Camera's position, clear flags and clipping plane distances will be used to render into cubemap faces. faceMask is a bitfield indicating which cubemap faces should be rendered into. Each bit that is set corresponds to a face. Bit numbers are integer values of CubemapFace enum. By default all six cubemap faces will be rendered (default value 63 has six lowest bits on).


This function will return false if rendering to cubemap fails. Some graphics hardware does not support the functionality.


Note: This is a Unity PRO feature.

注意:这是一个Unity 专业版属性

// Render scene from a given point into a static cube map.


// Place this script in Editor folder of your project.


// Then use the cubemap with one of Reflective shaders!

//然后用一个Reflective shaders 来使用这个立方贴图

class RenderCubemapWizard extends ScriptableWizard {

	var renderFromPosition : Transform;

	var cubemap : Cubemap;

	function OnWizardUpdate () {

		helpString = "Select transform to render from and cubemap to render into";

		isValid = (renderFromPosition != null) && (cubemap != null);


	function OnWizardCreate () {

		// create temporary camera for rendering


		var go = new GameObject( "CubemapCamera", Camera );

		// place it on the object


		go.transform.position = renderFromPosition.position;

		go.transform.rotation = Quaternion.identity;

		// render into cubemap

		//渲染到立方贴图 cubemap );

		// destroy temporary camera


		DestroyImmediate( go );


	@MenuItem("GameObject/Render into Cubemap")

	static function RenderCubemap () {


		"Render cubemap", "Render!");