学习Unity脚本推荐:Unity3D官网索引
Notification Center,顾名思义,就是用来处理各种通知的信息中心。
Unity3D的官网解释如下:
Notification Center的脚本源码如下:
import System.Collections.Generic;
// NotificationCenter is used for handling messages between GameObjects.
// GameObjects can register to receive specific notifications. When another objects sends a notification of that type, all GameObjects that registered for it and implement the appropriate message will receive that notification.
// Observing GameObjetcs must register to receive notifications with the AddObserver function, and pass their selves, and the name of the notification. Observing GameObjects can also unregister themselves with the RemoveObserver function. GameObjects must request to receive and remove notification types on a type by type basis.
// Posting notifications is done by creating a Notification object and passing it to PostNotification. All receiving GameObjects will accept that Notification object. The Notification object contains the sender, the notification type name, and an option hashtable containing data.
// To use NotificationCenter, either create and manage a unique instance of it somewhere, or use the static NotificationCenter.
// We need a static method for objects to be able to obtain the default notification center.
// This default center is what all objects will use for most notifications. We can of co