Hey guys, new here!
I’m having trouble understanding how am i supposed to expose an array of resources (or for what matters an array of Ref wrapped RefCounted instances) in GDExtension.
Here is an (non-working) example of how I would do it:
also the Terrain3D project is up on github and a great example of a GDExtension that has a resource it defines that uses an array of images (or textures, anyways). Maybe check that out too.
So… I’ve been experimenting a bit and i finally figured it out.
Here is how to expose and array of Ref<WhateverRefCounted> as a property of a node/resource.
Use the MAKE_TYPED_ARRAY and MAKE_TYPED_ARRAY_INFO macros with your Ref<Whatever> as first parameter and Variant::OBJECT for the second parameter. To avoid re-declarations I suggest doing this in a separate file since this macros declare new types.
Use TypedArrays (not Vector like i did in my first example).
Do not pass values to the setters by reference, only by value.
When binding your property, in the PropertyInfo use PROPERTY_HINT_TYPE_STRING as property hint and for the hint string pass String::num(Variant::OBJECT) + "/" + String::num(PROPERTY_HINT_RESOURCE_TYPE) + "Image" with the intended resource type instead of “Image” (source: this post)
I tested this a lil bit and it seems to function as it should, I hope your PC doesn’t explode because of me.
I hope to have been helpfull.