Created
October 19, 2016 23:23
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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