Game Development Reference
In-Depth Information
Figure 3-10. Creating two additional objects in the scene to test the NotificationsManager
To detect live keyboard input and to post appropriate notifications at the NotificationsManager, we'll
need to create a new script file in the project. This will be attached to obj_Poster . See Listing 3-14
for the code I'm using. Drag and drop this script file into the obj_Poster to add it as a component.
Listing 3-14. Detecting Keyboard Input and Posting Notifications (Poster.cs)
01 using UnityEngine;
02 using System.Collections;
03
04 public class Poster : MonoBehaviour
05 {
06 //Reference to gloabl Notifications Manager
07 public NotificationsManager Notifications = null;
08
09 // Update is called once per frame
10 void Update ()
11 {
12 //Check for keyboard input
13 if(Input.anyKeyDown && Notifications != null)
14 Notifications.PostNotification(this, "OnKeyboardInput");
15 }
16 }
 
Search WWH ::




Custom Search