12345678910111213141516171819202122232425262728293031323334353637 |
- using UnityEngine;
- using System.Collections;
- using TMPro;
- public class LivesRequestsCounter : MonoBehaviour
- {
- public TextMeshProUGUI notificationCount;
- void Awake()
- {
- MessageCenter.AddReceivedRequestsListener(OnReceivedRequests);
- FacebookHelper.AddLogoutListener(OnLogout);
- }
- void OnDestroy()
- {
- MessageCenter.RemoveReceivedRequestsListener(OnReceivedRequests);
- FacebookHelper.RemoveLogoutListener(OnLogout);
- }
- void OnReceivedRequests(ReceivedRequestsArgs requests)
- {
- int totalLifeRequests = requests.lifeDemandRequests.Count + requests.lifeRequests.Count;
- if (totalLifeRequests > 0)
- {
- notificationCount.text = totalLifeRequests.ToString();
- } else
- {
- notificationCount.text = "";
- }
- }
- void OnLogout()
- {
- notificationCount.text = "";
- }
- }
|