This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+4 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:

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:

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 (16 points)

1 Answer

+4 votes

I know this is an old post but it has not been answered. I hit the same problem.

After some experimenting I discovered all objects passed as parameters in an EmitSignal calls must inherit from Godot.Object or a descendant type.

by (94 points)
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.