I’m making an Editor script in order to tranfsorm my textures into Cubemap materials, I’m ok with it excepted for the texture shape that I need to change from 2D to Cube.
Anyone having the attribute or function to use for it ?
If you have an existing Texture2D asset and want to convert it to a cubemap, there’s no built in support for that. You would have to write pretty much all of that functionality on your own (determine if you have a 360 panorama or 6 faces, and either apply the appropriate transforms or copy the appropriate regions into a new CubeMap asset).
If you have an image file on disk, you can modify the texture importer settings for that texture:
My hack, assuming you don’t need this at runtime, is to save out a Texture2D to disk and reimport using the texture importer rather than reinvent the wheel.
I don’t need to script a conversion to a Cubemap material (if it’s what you were talking about), I already have this part of the code (creating the material and applying a Cube texture), and it’s always a Cubemap, never a 6-faces.
The only action I still have to do now is what would be manually : click the Texture’s “Texture Shape” attribute, select “Cube” and press “Apply”. The rest will follow easily.
I’ll still watch at your suggestion, but it looks at me like it’s going a bit too far for my problem
EDIT : Haven’t resolved yet, but the TextureImporter actually looks great… Its textureShape attribute is exactly what I were looking at, trying to find a way with that.
Hello there! Is there a way to get the path from WWW.texture? I’m trying to change the shape from a online image which is Texture2D to texture shape “CUBE”?
So, “yes”, you can construct a cube map in real time. “No” you can’t change the “shape” since that’s purely a texture importer thing and that doesn’t do anything at runtime.