Skip to content

Instantly share code, notes, and snippets.

@kirillrybin
Created June 5, 2014 13:12
Show Gist options
  • Save kirillrybin/1f82720e709b714c1f0b to your computer and use it in GitHub Desktop.
Save kirillrybin/1f82720e709b714c1f0b to your computer and use it in GitHub Desktop.
GenerateStaticCubemap
using UnityEngine;
using UnityEditor;
public class GenerateStaticCubemap : ScriptableWizard {
public Transform renderPosition;
public Cubemap cubemap;
void OnWizardUpdate(){
helpString = "Select transform to render from and cubemap to render into";
if (renderPosition != null && cubemap != null){
isValid = true;
} else {
isValid = false;
}
}
void OnWizardCreate(){
var go = new GameObject("CubeCam", typeof(Camera));
go.transform.position = renderPosition.position;
go.transform.rotation = Quaternion.identity;
go.camera.RenderToCubemap(cubemap);
DestroyImmediate(go);
}
[MenuItem("Window/Render Cubemap")]
static void RenderCubemap(){
ScriptableWizard.DisplayWizard("Render CubeMap", typeof(GenerateStaticCubemap), "Render!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment