Quantcast
Channel: Latest Questions by TheShadyColombian
Viewing all articles
Browse latest Browse all 145

RenderToCubemap not saving texture to disk

$
0
0
I'm trying to use the [RenderToCubemap wizard that's posted on the Unity docs][1], 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(); // place it on the object go.transform.position = renderFromPosition.position; go.transform.rotation = Quaternion.identity; // render into cubemap go.GetComponent().RenderToCubemap(cubemap); // destroy temporary camera DestroyImmediate(go); } [MenuItem("GameObject/Render into Cubemap")] static void RenderCubemap() { ScriptableWizard.DisplayWizard( "Render cubemap", "Render!"); } } [1]: https://docs.unity3d.com/ScriptReference/Camera.RenderToCubemap.html

Viewing all articles
Browse latest Browse all 145

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>