Pass Variant to Native

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Beliar

Heya,

I am having trouble getting a Variant to correctly be passed to a native library.

I have a this method that goes like this:

void My::print(const Variant &p_value) {
std::stringstream test;
test << p_value.get_type();
Godot::print(test.str().c_str());
}

I am registering it like this:

register_method("print", &My::print);

When I call it from a GDScript like this:

My.print(Vector2(10,10))

I get the following output:

0

Anyone have an idea what I am missing? I have already checked how other methods (like json) do this, and it does not look different.

:bust_in_silhouette: Reply From: Beliar

Okay, the Problem was fixed by changing the method to this:

void My::print(Variant p_value) {
std::stringstream test;
test << p_value.get_type();
Godot::print(test.str().c_str());
}