- Home /
Question by
thunderwiring · Jan 18 at 11:27 AM ·
c#cubemap
Error assigning 2D texture to CUBE texture property '_Tex': Dimensions must match
i have Texture2D that i want to render on a cubemap:
int width = 600;
int height = 600;
Texture2D tex = new Texture2D(width, height, TextureFormat.RGB24, false);
tex.Apply();
<call native plugin function that assigns an image to the texture>
Color[] pixels = tex.GetPixels();
Cubemap cube = new Cubemap(width, TextureFormat.RGB24, false);
cube.SetPixels(pixels, CubemapFace.PositiveY);
cube.SetPixels(pixels, CubemapFace.PositiveX);
cube.SetPixels(pixels, CubemapFace.PositiveZ);
cube.SetPixels(pixels, CubemapFace.NegativeY);
cube.SetPixels(pixels, CubemapFace.NegativeZ);
cube.SetPixels(pixels, CubemapFace.NegativeX);
cube.Apply();
material.SetTexture("_Tex", tex);
sphereRenderer.material = material;
i get the error Error assigning 2D texture to CUBE texture property '_Tex': Dimensions must match
what dimensions the error is referring to? and what's the right way of assigning an image to cubemap faces?
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613051708im_/https://answers.unity.com/themes/thub/images/avi.jpg)