![]() ![]() Let’s take the previous example and tweak it a little bit. This class is a standard PlayableBehaviour, so it can be added to any graph, only with some more logic to send a notification at a precise time. I can use the built-in class TimeNotificationBehaviour for that. Now that we know how to send a notification through a playable graph, let’s schedule a notification so that it is sent at a time of our choosing. The receiver correctly received a notification, but how can I control the time at which the notification is sent? We’ll need more help to achieve that. Received notification of type MyNotification at time 0 When transitioning in playmode, this message appears in the console: When the graph is played, the OnNotify method will be called on the m_Receiver instance with the notification that was sent as an argument. Once all the notifications are sent, the queue is cleared before a new frame begins. Immediately before the LateUpdate stage, all queued notifications will be sent to the graph’s outputs. This means that they will be accumulated until the graph has been processed completely. ![]() Output.PushNotification(Playable.Null, new MyNotification()) īeware! Notifications are not sent as soon as you call PushNotification they are only queued. Output.AddNotificationReceiver(m_Receiver) Var output = ScriptPlayableOutput.Create(m_Graph, "NotificationOutput") M_Graph = PlayableGraph.Create("NotificationGraph") public class ManualNotification : MonoBehaviour ![]() I can push a new notification using the PushNotification method from the playable output. The m_Receiver instance will now be able to receive notification sent to this output.Įverything is now in place to send a notification. I added a ReceiverExample to the playable output (using the AddNotificationReceiver method). In the following example, I created a new playable graph and a new playable output. Public void OnNotify(Playable origin, INotification notification, object context)ĭouble time = origin.IsValid() ? origin.GetTime() : 0.0 ĭebug.LogFormat("Received notification of type ", notification.GetType(), time) class ReceiverExample : INotificationReceiver For this example, I have a receiver that will print the time at which a notification was received. Then, I need a receiver: a class that implements the INotificationReceiver interface. For these examples, I don’t really need it, so I will use the default implementation. We can use the id property to uniquely identify the notification. public class MyNotification : INotification I will build a simple graph and manually send a notification.įirst, I need to create a notification: a class that implements the INotification interface. Playable Notifications can be used to inform a target object that an event occurred. The Playable API allows notifications to be sent to an object while a PlayableGraph is processed. ![]()
0 Comments
Leave a Reply. |