0 votes

I have a question about exporting typed arrays in GDExtension. What I want is to achieve in C++ is something along the lines of

@export var textures: Array[Texture]

or even

@export var my_elems: Array[MyBaseClassWithPossibleChildClasses]

I need to export it I think in _bind_methods() function, and the export requires providing the correct godot::PropertyInfo. I can't figure out which parameters to use to export a typed array. Also, I want to use reference to an object which can be a different subclass of a base class.


More specific example: base class UserController, and descendants PlayerController, AiController, ReplayController etc. And the list of all possible controllers:

@export var controllers: Array[UserController]

which can contain any number of PlayerController, AiController, ReplayController instances.
It's not the only case, there are other cases like that.

All the classes I want to be exported are derived from Resource class.


Is it possible to implement in Godot 4.0 beta 2? If not directly, are there any workarounds for this?

Godot version 4.0 beta 2
in Engine by (12 points)

I am trying to do this currently, did you ever figure it out?

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.