Skip to content

Instantly share code, notes, and snippets.

@prehnRA
Created October 19, 2016 23:23
Show Gist options
  • Save prehnRA/f37ab80bf48a28f9856248066499983e to your computer and use it in GitHub Desktop.
Save prehnRA/f37ab80bf48a28f9856248066499983e to your computer and use it in GitHub Desktop.
A script to capture a scene to a cubemap asset for use as a sky box
using UnityEngine;
using UnityEditor;
public class SkyboxCamera : MonoBehaviour {
const int TEXTURE_SIZE = 1024;
void Update() {
if(Input.anyKey) {
Capture();
}
}
void Capture() {
Cubemap cubemap = new Cubemap(TEXTURE_SIZE, TextureFormat.ARGB32, true);
cubemap.name = "Skybox";
Camera camera = GetComponent<Camera>();
camera.RenderToCubemap(cubemap);
AssetDatabase.CreateAsset(
cubemap,
"Assets/Textures/Skybox/Skybox.cubemap"
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment