Exemplo n.º 1
0
        private string GetPrintStr(NetMetaInfo info, Text text = null)
        {
            string str = "";

            if (info.data.PackType == PackData.EPackType.Recv)
            {
                str = String.Format("{0}recv protocol => {1}\n{2}", HEADER, info.data.Protocol, info.data.GetJson());
                if (text)
                {
                    text.color = Color.yellow;
                }
            }
            else
            {
                str = String.Format("{0}send protocol => {1}\n{2}", HEADER, info.data.Protocol, info.data.GetJson());
                if (text)
                {
                    text.color = Color.green;
                }
            }

            if (text)
            {
                text.text = str;
            }

            return(str);
        }
Exemplo n.º 2
0
        public void PushLog(PackData data)
        {
            FreeLogList();

            NetMetaInfo info = pool.Get();

            info.data = data;

            logList.Add(info);

            if (isShow)
            {
                AddTemplate(info, logList.Count - 1);
            }
        }
Exemplo n.º 3
0
        private void AddTemplate(NetMetaInfo info, int index)
        {
            if (info.obj != null)
            {
                return;
            }

            var gameobj = cache.GetTemplate(TEMPLATE_ITEM_STR, logTemplate.transform.parent, true);

            var text = gameobj.GetComponent <Text>();

            GetPrintStr(info, text);

            gameobj.transform.SetSiblingIndex(index);

            info.obj = gameobj;

            if (scrollRect.verticalNormalizedPosition < 0.1f)
            {
                ScrollToBottom();
            }
        }
Exemplo n.º 4
0
 public void Free(NetMetaInfo info)
 {
     info.obj  = null;
     info.data = null;
 }