topical media & game development
lib-unity-demo-sewer-Assets-Editor-RenderCubemap.js / js
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 );
go.camera.backgroundColor = Color.black;
go.camera.cullingMask = ~(1<<8);
// place it on the object
go.transform.position = renderFromPosition.position;
if( renderFromPosition.renderer )
go.transform.position = renderFromPosition.renderer.bounds.center;
go.transform.rotation = Quaternion.identity;
// render into cubemap
go.camera.RenderToCubemap( cubemap );
// destroy temporary camera
DestroyImmediate( go );
}
@MenuItem("Custom/Render into Cubemap", false, 4)
static function RenderCubemap()
{
ScriptableWizard.DisplayWizard(
"Render cubemap", RenderCubemapWizard, "Render!");
}
}
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.