- Home /
RenderToCubemap not saving texture to disk
I'm trying to use the RenderToCubemap wizard that's posted on the Unity docs, and it works fine except when I open the texture outside of unity, the texture is blank, instead of containing the baked cubemap.
To clarify, I can see the baked image when looking at the cubemap texture, or a Skybox>Cubemap material that the cubemap has been applied to through the Inspector, but when I use it for reflections in the lighting window, or when I open it outside of unity, the image is just blank (which is what it was when it was created, since you have to provide an existing texture for the wizard to bake to)
Here's the code exactly as shown on the docs:
using UnityEngine;
using UnityEditor;
using System.Collections;
public class RenderCubemapWizard : ScriptableWizard
{
public Transform renderFromPosition;
public Cubemap cubemap;
void OnWizardUpdate()
{
string helpString = "Select transform to render from and cubemap to render into";
bool isValid = (renderFromPosition != null) && (cubemap != null);
}
void OnWizardCreate()
{
// create temporary camera for rendering
GameObject go = new GameObject("CubemapCamera");
go.AddComponent<Camera>();
// place it on the object
go.transform.position = renderFromPosition.position;
go.transform.rotation = Quaternion.identity;
// render into cubemap
go.GetComponent<Camera>().RenderToCubemap(cubemap);
// destroy temporary camera
DestroyImmediate(go);
}
[MenuItem("GameObject/Render into Cubemap")]
static void RenderCubemap()
{
ScriptableWizard.DisplayWizard<RenderCubemapWizard>(
"Render cubemap", "Render!");
}
}
Your answer
Follow this Question
Related Questions
Physic Material Friction Combine Mode lack of documentation? 2 Answers
Generating (HTML) documentation for Unity Script (not C#) ? (like Doxygen) 1 Answer
Networking Destroy Player's RPC function uhm WHAT? 1 Answer
uGUI API Documentation 2 Answers
Current (5.3) Documentation (Manual and Scripting Reference) Download 2 Answers