Import a spherical image and save as the cubemap of a material by script (Unity 5)
Hi, I am new to Unity. I want to import a spherical image
and set it as the skybox of my scene. I can do it easily using the editor but now I need to do this using script. I have read many posts but can't solve this.
I have my url and did something like this:
WWW www = new WWW (url); //get my image using url
Material mat = new Material (Shader.Find("Skybox/Cubemap")); //set the shader to Cubemap mode
mat.SetTexture ("_Cube", www.texture); //set the texture to the spherical image I just imported
AssetDatabase.CreateAsset (mat, "Assets/mymaterial.mat"); //save it
RenderSettings.skybox = mat; //set the skybox
If I use "_Cube"
, my Cubemap (HDR) is none. If I use "_Tex"
, I got Error assigning 2D texture to cubemap texture property '_Tex': Dimensions must match
I know www.texture
is a 2D texture but I don't know how to save it as a spherical image.
I think I need something similar to TextureImporterGenerateCubemap.Cylindrical
I also don't know how to set the cubemap mapping
to Cylindrical
Thanks for any help!
Your answer
Follow this Question
Related Questions
Converting Cubemaps to Panoramic images? 0 Answers
Shadergraph Day-night cycle 0 Answers
Converting Cubemaps to Panoramic images? 0 Answers
HDRI Sky Cubemap won't update 1 Answer
Converting Cubemaps to Panoramic images? 0 Answers