Home

Awesome

GodotNotificationCenter

A notification center for Godot Engine

Compatible with Godot 3

Check branch 2.0 for a project compatible with Godot 1.1 and 2.x

Installation

Just add notification_center.gd to the autoload settings of your project

You only need the notification_center.gd script.

Check the demo project for more info.

Usage

Notifications are sent to observers. Any object can be an observer. Notifications can be sent from anywhere in your code.

If you need to add an observer or send a notification, get the root object:

var nc = get_node("/root/nc") # if you named it nc in the autoload settings

OR

var nc = $"/root/nc" # new Godot 3 syntax

To add an object as observer

nc.add_observer(observer,notificationName,action)

func action(observer,notificationName,notificationData):

To remove an observer

nc.remove_observer(observer, notificationName)

you MUST remove an observer, at least when it leaves the scene. Example:

func _exit_tree():
    nc.remove_observer(self, notificationName)

To send a notification

nc.post_notification(notificationName,notificationData)

Every observer of notificationName will execute its action.

Licence

MIT