Cannot make arrays of CompressedTexture2D

Godot Version

v4.2.1.stable.mono.official [b09f793f5]


I have a script attached to a plain Node which contains the following array of CompressedTexture2D for some textures I want to blit into a larger texture:

public CompressedTexture2D[ ] images;

however I get a strange error if I try and add an image to this array in the editor:

Attempted to set an object of type ‘CompressedTexture2D’ into a TypedArray, which does not inherit from ‘Image’.
core/variant/array.cpp:413 - Condition “!_p->typed.validate(value, “set”)” is true.

I couldn’t find any info on this error or why its happening. If I use an Image array it works fine.

Make sure that the resources that you are trying to add are imported as Texture2D and not as Image or any other type by selecting the file in the FileSystem dock and checking that the file is imported as Texture2D in the Import dock.

Also, it would be better to export a Texture2D array as it will have more flexibility.

Thanks for reply - the problem though is when I do try and import as Texture2D rather than Image…

I’ve tried changing the node to inherit from Node2D which now displays the texture in the editor (but the goes empty again when changing to a different node and then back again) but it doesn’t really work and now gives the error:

Failed to set a resource of the type ‘Image’ because this EditorResourcePicker only accepts ‘CompressedTexture2D’ and its derivatives.

It is a CompressedTexture2D :o. The texture will not display in-game either.

EDIT: If I ditch the array and just have 5 separate properties it actually works but forces the textures to RGB8. I’ve gone back to just using Image as it seems to be more trouble than its worth.

Did you alt + b? for build your C# in editor. is look like your export is still CompressedTexture2D and your dirt is texture2D

Yes, the solution is built in VS ok and it comes across as a CompressedTexture2D (though it does say ‘Texture2D’ in the editor under ‘import as’). It feels like some kind of bug perhaps though I’m pretty new to Godot.