Creating Texture2DArray as asset

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?

1 Like

Best guess is this:

I haven’t tried doing this yet and I find it odd that it lets you make an asset with a different extension if it doesn’t support it, and that said asset shows up in the project view still. It’s plausible that your .tarr extension is fine and that documentation is wrong.

Thanks! I missed that line in documentation :slight_smile: Knew that has something to do with extension, but didn’t know which one to choose. It’s weird that Unity is so extension-dependent. Anyway, that works fine now!