Hello!
Trying to test new Unity Texture array feature, but it seems I’m missing something with texture2DArray creation as asset.
I’m saving Texture2DArray using following code:
Object[] selection = Selection.objects;
Texture2D[] textures = new Texture2D[selection.Length];
for (int i = 0; i < textures.Length; i++)
{
textures[i] = (Texture2D)selection[i];
}
Texture2DArray array = new Texture2DArray(textures[0].width, textures[0].height, textures.Length, textures[0].format, false);
for (int i = 0; i < textures.Length; i++)
array.SetPixels(textures[i].GetPixels(), i);
array.Apply();
AssetDatabase.CreateAsset(array, "Assets/TextureArray.tarr");
while asset is created fine, I can’t assign it to my shader or script through inspector. Shader code copied from Unity Documentation, so I assume it’s fine. Can anyone tell what am I doing wrong?