Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/didier-v/GodotNotificationCenter
A notification center for Godot Engine
https://github.com/didier-v/GodotNotificationCenter
godot godot-engine notifications
Last synced: 6 days ago
JSON representation
A notification center for Godot Engine
- Host: GitHub
- URL: https://github.com/didier-v/GodotNotificationCenter
- Owner: didier-v
- License: mit
- Created: 2015-08-27T04:53:48.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2019-03-13T17:56:19.000Z (over 5 years ago)
- Last Synced: 2024-08-02T06:16:46.474Z (3 months ago)
- Topics: godot, godot-engine, notifications
- Language: GDScript
- Size: 20.5 KB
- Stars: 58
- Watchers: 2
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-godot - GodotNotificationCenter - A notification center (Godot 3.x). (Plugins and scripts / 3D)
- awesome-godot-3 - GodotNotificationCenter - A notification center (Godot 3.x). (Plugins and scripts / 3D)
- awesome-godot-3 - GodotNotificationCenter - A notification center (Godot 3.x). (Plugins and scripts / 3D)
README
# GodotNotificationCenter
A notification center for [Godot Engine](https://github.com/godotengine/godot)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 projectYou 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)`* observer is the object added as an observer
* notificationName is the ID of the notification. It is a String.
* action is the name of a function that must be defined by the observer with 3 parameters:
`func action(observer,notificationName,notificationData):`
* notificationData can by of any type. You can make a dictionary and include every needed data in it. It is sent with the notification.
## 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