ChatIcon.cs 591 B

123456789101112131415161718192021222324252627282930313233
  1. using UnityEngine;
  2. using System.Collections;
  3. public class ChatIcon : MonoBehaviour
  4. {
  5. public ChatBar chatBar;
  6. // Use this for initialization
  7. void Start ()
  8. {
  9. ChatManager.GetInstance ().MsgUpdate.AddListener (OnMsgUpdate);
  10. }
  11. private void OnMsgUpdate()
  12. {
  13. if (chatBar.isShown) {
  14. RedDot.SetValue (this.transform, 0);
  15. return;
  16. }
  17. ChatManager chatMan = ChatManager.GetInstance ();
  18. int value = chatMan.GetNewMsgGlobalCount ();
  19. RedDot.SetValue (this.transform, value);
  20. }
  21. void OnDestroy()
  22. {
  23. ChatManager.GetInstance ().MsgUpdate.RemoveListener (OnMsgUpdate);
  24. }
  25. }