12345678910111213141516171819202122232425262728293031323334353637 |
- using UnityEngine;
- using System.Collections;
- public class ChallengeRequestsCounter : MonoBehaviour
- {
- public UILabel 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 = "";
- }
- }
|