+2 votes

I'm trying to send a custom class InvItem through a signal _UpdateHotbarItem. When the signal is declared as this in the Inventory.cs class:

[Signal]
public delegate void _UpdateHotbarItem(string id, int index, bool side, string data);

it's fine. However, when I add InvItem item to the parameters and build the project, the signal disappears from the signal list in the editor and I get a couple errors. On startup, I get _get_signal: Unknown type of signal parameter 'item' in 'Inventory'. On signal connection, I get connect: In object of type 'Area2D': Attempt to connect nonexistent signal '_UpdateHotbarItem' to method 'KinematicBody2D.UpdateHotbarItem, and on emitting the signal, I get two more errors, Attempted to convert an unmarshallable managed type to Variant. Name: 'InvItem' Encoding: 18, and Can't emit non-existing signal "_UpdateHotbarItem".

When I remove the InvItem item, and change the signal emitters and receiving methods, all four of those errors disappear.
In both cases, the InvItem export I have, shown here:

[Export]
InvItem heldItem = null;

throws an error, this error being _get_member_export: Unknown exported member type: 'Inventory.heldItem'.

It seems to me that Godot doesn't realize the InvItem class in the CustomDataTypes namespace in CustomDataTypes.cs exists. How do I get Godot to recognize it, so I can use it in signals, export statements, and similar things?

in Engine by (14 points)

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 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 webmaster@godotengine.org with your username.