https://github.com/officialduke99/signalprinter
Godot plugin for monitoring signals of a global EventBus singleton.
https://github.com/officialduke99/signalprinter
debugging game-development godot godot-engine godot-plugin godot4 logging printing tool
Last synced: 4 months ago
JSON representation
Godot plugin for monitoring signals of a global EventBus singleton.
- Host: GitHub
- URL: https://github.com/officialduke99/signalprinter
- Owner: officialduke99
- License: unlicense
- Created: 2024-08-15T15:28:56.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-08-15T18:47:30.000Z (10 months ago)
- Last Synced: 2025-01-31T04:24:38.681Z (5 months ago)
- Topics: debugging, game-development, godot, godot-engine, godot-plugin, godot4, logging, printing, tool
- Language: GDScript
- Homepage:
- Size: 47.9 KB
- Stars: 10
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# SignalPrinter

_Plugin for monitoring signals of a global EventBus singleton._
While creating Godot projects, developers often use a global signal script, a singleton, which houses only signals needed for unrelated systems to talk to each other. These scripts go by names like EventBus, MessageBus, Signalton, etc. One downside these scripts often have is the inability to see under the hood, as there isn't an easy way to monitor multiple signals being emitted. Developers often have to resort to using `print()` statements on each end of the signal path.
This plugin adds a `SignalPrinter` node, which automatically connects to all signals of your global EventBus and routes them to a method, which prints the signal's name, all arguments and (optionally) the time at which the signal was recieved.
Example output:
>**player_interacted**
with : Node3D = Pickup: _// The type is the same as was declared in the signal itself_
time (ticks msec) = 4647>**inventory_item_changed**
item : Item = _// It even recognizes custom Resource types (Item)_
index : int = 1 _// And has support for Variant types_
time (ticks msec) = 17442
## Usage
You **need** to replace `global_bus` in [signal_printer.gd](addons/signal_printer/signal_printer.gd) script with your own singleton's reference. Otherwise you get an error.### Example
If your global bus is named `EventBus`, you simply replace null with EventBusFrom:
`static var global_bus : Node = null` :x:To:
`static var global_bus : Node = EventBus` :heavy_check_mark:You pass the singleton in directly, not by its name.
`static var global_bus : Node = "EventBus"` :x:After that, you can add this node anywhere in the scene and remove it, when you don't need it anymore.
 ### Warning
As GDScript currently doesn't support variable argument count, arguments in the function are added manually. Currently, the _max argument count per signal is **10**_, but if you need more, you can add them easily.## Further reading
[How to create an EventBus in Godot](https://www.gdquest.com/tutorial/godot/design-patterns/event-bus-singleton/)
[Theory behind the Observer pattern](https://gameprogrammingpatterns.com/observer.html)