Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | GalaxyGamingBoy |
I have a class named SignalOrigin.cs and another class named EmitSignalTest.cs
The signal however is not found! ( I am new to Godot C# )
Here is the code:
( SignalOrigin.cs )
[Signal]
delegate void CreateBlock();
public void ABlock()
{
GD.Print("HELLO");
}
public override void _Ready()
{
this.Connect(nameof(CreateBlock), this, "ABlock");
}
( EmitSignalTest.cs )
if (Input.IsActionJustPressed("ui_accept"))
{
if(Materials[0] > 0)
{
EmitSignal("CreateBlock");
}
}
The EmitSignal
method and the signal delegate have to be in the same class.
The Signal then shows in the editor. Form there you can choose the target node/script.
That should help you: https://docs.godotengine.org/en/stable/getting_started/step_by_step/signals.html
juppi | 2021-12-04 18:25
Thank you, very much! For the first time I didn’t understand the docs. Thank you for your help!
GalaxyGamingBoy | 2021-12-04 21:05