Reputation: 76
I am currently making a 360-degree picture viewer in Unity for Android. All equirectangular pictures are loaded in the resources folder.
I want to know if TextureImporter class can be used to convert the 2d textures into Cubemap during runtime.
Currently, I am converting the 2d textures into Cubemaps. Created materials for each on of it. And loading this material under skybox component added in Main camera. The downside of using this approach is the apk size more than 250 mb.
If I could make cube maps on the fly I could save some good amount of space.
Please help!
Upvotes: 0
Views: 931
Reputation: 125275
I want to know if TextureImporter class can be used to convert the 2d textures into Cubemap during runtime.
No, it can't.
See the doc for TextureImporter
. It is a class in the UnityEditor
namespace. Any class or API in that namespace cannot be used in a build It is only made for Editor use only.
You might be able to use the Cubemap
class to create a cubemap. You can use Texture2D.GetPixels();
to get the Texture's pixels and Cubemap.SetPixels()
to set the pixels to the cubemap.
For example:
public Cubemap c;
private Color[] CubeMapColors;
public Texture2D t;
void Start()
{
CubeMapColors = t.GetPixels();
c.SetPixels(CubeMapColors, CubemapFace.PositiveX);
c.Apply();
}
Upvotes: 2