godotengine / godotengine/godot-cpp
How to initialize a custom class with parameters
- Dominant language
- C++
- Stars
- 2.7k
- Forks
- 809
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 8
Description
Hi there,
I wondered if it was possible to instantiate a custom GDNative class with arguments in GDNative code.
This could be useful in several situations e.g. :
1. class with const members which require a parametrized constructor with initialization list
2. inline-style instanciation like `some_function(some_class::_new(/* some arguments */));`
As far as I understand GDNative library, it seems a custom class `some_class` is intanciated by `NativeScript::new_()` itself called from the `some_class::_new()` function itself inserted by the `GODOT_CLASS()` macro.
However in this processus no argument is passed.
Anyone could tell me a bit more about how to use the C++ constructors and/or the `_init()` method to pass arguments upon instanciation ?
Best
Flarkk
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.