using UnityEngine; using System.Collections; public class AnnouncementManager : MonoBehaviour { public Transform announcementsAnchor; public PoolObject announcementPrefab; Pool _announcementsPool; void Awake() { _announcementsPool = Pool.Create(announcementPrefab, 5); NotificationCenter.AddListener(OnAnnouncement, NotificationType.Announcement); } void OnDestroy() { NotificationCenter.RemoveListener(OnAnnouncement, NotificationType.Announcement); } void OnAnnouncement(Notification note) { string text = (string)note.data; TextAnnouncement announcement = _announcementsPool.Spawn().GetComponent(); Transform hitPointsBonusTransform = announcement.transform; hitPointsBonusTransform.parent = announcementsAnchor; announcement.SetText(text); hitPointsBonusTransform.localPosition = Vector3.zero; } }