using UnityEngine; using System.Collections; public class ChatIcon : MonoBehaviour { public ChatBar chatBar; // Use this for initialization void Start () { ChatManager.GetInstance ().MsgUpdate.AddListener (OnMsgUpdate); } private void OnMsgUpdate() { if (chatBar.isShown) { RedDot.SetValue (this.transform, 0); return; } ChatManager chatMan = ChatManager.GetInstance (); int value = chatMan.GetNewMsgGlobalCount (); RedDot.SetValue (this.transform, value); } void OnDestroy() { ChatManager.GetInstance ().MsgUpdate.RemoveListener (OnMsgUpdate); } }