Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

Signal

A built-in type representing a signal of an Object.

Description

Signal is a built-in Variant type that represents a signal of an Object instance. Like all Variant types, it can be stored in variables and passed to functions. Signals allow all connected Callables (and by extension their respective objects) to listen and react to events, without directly referencing one another. This keeps the code flexible and easier to manage.

In GDScript, signals can be declared with the signal keyword. In C#, you may use the [Signal] attribute on a delegate.

signal attacked

# Additional arguments may be declared.
# These arguments must be passed when the signal is emitted.
signal item_dropped(item_name, amount)

Примітка

There are notable differences when using this API with C#. See Відмінності API C# в GDScript for more information.

Tutorials

Constructors

Signal

Signal ( )

Signal

Signal ( Signal from )

Signal

Signal ( Object object, StringName signal )

Methods

int

connect ( Callable callable, int flags=0 )

void

disconnect ( Callable callable )

void

emit ( ... ) vararg const

Array

get_connections ( ) const

StringName

get_name ( ) const

Object

get_object ( ) const

int

get_object_id ( ) const

bool

is_connected ( Callable callable ) const

bool

is_null ( ) const

Operators

bool

operator != ( Signal right )

bool

operator == ( Signal right )


Constructor Descriptions

Signal Signal ( )

Constructs an empty Signal with no object nor signal name bound.


Signal Signal ( Signal from )

Constructs a Signal as a copy of the given Signal.


Signal Signal ( Object object, StringName signal )

Creates a new Signal named signal in the specified object.


Method Descriptions

int connect ( Callable callable, int flags=0 )

Connects this signal to the specified callable. Optional flags can be also added to configure the connection's behavior (see ConnectFlags constants). You can provide additional arguments to the connected callable by usi