1234567891011121314151617181920212223242526272829303132333435363738 |
- using UnityEngine;
- using System.Collections;
- using TMPro;
- public class ChallengeRequestsCounter : 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 challengeRequests = requests.challengeRequests.Count;
- if (challengeRequests > 0)
- {
- notificationCount.text = challengeRequests.ToString();
- } else
- {
- notificationCount.text = "";
- }
- }
- void OnLogout()
- {
- notificationCount.text = "";
- }
- }
|