void OnEnable() { m_InitTime = Time.time; if (m_DisplayMessageManager == null) { m_DisplayMessageManager = FindObjectOfType <DisplayMessageManager>(); } DebugUtility.HandleErrorIfNullFindObject <DisplayMessageManager, DisplayMessage>(m_DisplayMessageManager, this); }
// Update is called once per frame void Update() { if (!m_DisplayMessageManager) { m_DisplayMessageManager = FindObjectOfType <DisplayMessageManager>(); DebugUtility.HandleErrorIfNullFindObject <DisplayMessageManager, DisplayMessage>(m_DisplayMessageManager, this); } if (m_WasDisplayed) { return; } if (Time.time - m_InitTime > delayBeforeShowing) { var messageInstance = Instantiate(messagePrefab, m_DisplayMessageManager.DisplayMessageRect); var notification = messageInstance.GetComponent <NotificationToast>(); if (notification) { notification.Initialize(message); } m_WasDisplayed = true; } }
void Start() { m_InitTime = Time.time; m_DisplayMessageManager = FindObjectOfType <DisplayMessageManager>(); DebugUtility.HandleErrorIfNullFindObject <DisplayMessageManager, DisplayMessage>(m_DisplayMessageManager, this); }