/// <summary>
    /// 添加一条聊天信息
    /// </summary>
    /// <param name="text">聊天信息显示的内容</param>
    /// <param name="channel">聊天信息放至的频道</param>
    /// <param name="userId">发送玩家的ID</param>
    /// <param name="channelIcon">聊天信息发送的频道,用于显示频道图标</param>
    /// <param name="LvAndNameString">聊天信息的人名,用于计算下划线的长度</param>
    /// <param name="underLineColor">人名下划线颜色</param>
    /// <param name="lineOffsetX">人名下划线偏移,自己向别的玩家的私聊信息需处理</param>
    public void AddChatUIDialogText(string text, ChannelId channel, ulong userId,
                                    ChannelId channelIcon, string LvAndNameString = "", string underLineColor = "13FFD5", int lineOffsetX = 60)
    {
        string name = "WorldChannelDialogLabelList";

        int    m_iLineNum  = 0;
        int    m_iSpaceNum = 0;
        Camera relatedCam  = m_camWorldChannelCamera;


        AssetCacheMgr.GetUIInstance("ChatUIDialogLabel.prefab", (prefab, id, go) =>
        {
            GameObject obj = (GameObject)go;


            UILabel lblChatUIDialogLabelText     = obj.transform.Find("ChatUIDialogLabelText").GetComponentsInChildren <UILabel>(true)[0];
            lblChatUIDialogLabelText.effectStyle = UILabel.Effect.Outline;

            UISprite spChatUIDialogLabelChannel = obj.transform.Find("ChatUIDialogLabelChannel").GetComponentsInChildren <UISprite>(true)[0];
            SetChatUIDialogLabelChannel(channelIcon, spChatUIDialogLabelChannel);

            // 设置下划线
            UILabel lblChatUIDialogLabelUnderLine = obj.transform.Find("ChatUIDialogLabelUnderLine").GetComponentsInChildren <UILabel>(true)[0];
            float totalUnderline = m_inputText.label.font.CalculatePrintedSize(LvAndNameString, true, UIFont.SymbolStyle.None).x;
            float oneUnderLine   = m_inputText.label.font.CalculatePrintedSize("_", true, UIFont.SymbolStyle.None).x;
            int underLineCount   = (int)(totalUnderline / oneUnderLine);

            lblChatUIDialogLabelUnderLine.text = "";
            for (int i = 0; i < underLineCount; i++)
            {
                lblChatUIDialogLabelUnderLine.text += "_";
            }

            // 设置下划线颜色
            lblChatUIDialogLabelUnderLine.text = string.Concat("[", underLineColor, "]", lblChatUIDialogLabelUnderLine.text, "[-]");

            switch (channel)
            {
            case ChannelId.WORLD:
                name        = "WorldChannelDialogLabelList";
                m_iLineNum  = m_iLineNumWorld;
                m_iSpaceNum = m_iSpaceNumWorld;
                relatedCam  = m_camWorldChannelCamera;
                lblChatUIDialogLabelText.effectColor = new Color32(32, 19, 14, 255);
                break;

            case ChannelId.UNION:
                name        = "TongChannelDialogLabelList";
                m_iLineNum  = m_iLineNumTong;
                m_iSpaceNum = m_iSpaceNumTong;
                relatedCam  = m_camTongChannelCamera;
                lblChatUIDialogLabelText.effectColor = new Color32(0, 0, 0, 255);
                break;

            case ChannelId.PERSONAL:
                name        = "PrivateChannelDialogLabelList";
                m_iLineNum  = m_iLineNumPrivate;
                m_iSpaceNum = m_iSpaceNumPrivate;
                relatedCam  = m_camPrivateChannelCamera;
                lblChatUIDialogLabelText.effectColor = new Color32(13, 0, 16, 255);
                lblChatUIDialogLabelUnderLine.transform.localPosition = new Vector3(lineOffsetX,
                                                                                    lblChatUIDialogLabelUnderLine.transform.localPosition.y,
                                                                                    lblChatUIDialogLabelUnderLine.transform.localPosition.z);
                break;

            case ChannelId.SYSTEM:
                name        = "WorldChannelDialogLabelList";
                m_iLineNum  = m_iLineNumWorld;
                m_iSpaceNum = m_iSpaceNumWorld;
                relatedCam  = m_camWorldChannelCamera;
                lblChatUIDialogLabelText.effectColor = new Color32(0, 0, 0, 255);
                break;
            }

            obj.SetActive(true);
            obj.transform.parent            = m_myTransform.Find(m_widgetToFullName[name]);
            obj.transform.parent.localScale = new Vector3(0.0008f, 0.0008f, 1);
            obj.transform.localPosition     = Vector3.zero;
            obj.transform.localScale        = new Vector3(1, 1, 1);
            obj.transform.GetComponentsInChildren <MyDragCamera>(true)[0].RelatedCamera = relatedCam;

            string strTmp = text;

            for (int i = 0; i < text.Length; ++i)
            {
                if (text[i] == '<' && text.Substring(i).Length >= 6 && text.Substring(i, 6) == "<info=")
                {
                    int tmp = i + 7;

                    while (tmp < text.Length)
                    {
                        if (text[tmp] == '>')
                        {
                            float length = m_inputText.label.font.CalculatePrintedSize(text.Substring(0, i), true, UIFont.SymbolStyle.None).x;

                            string originString = text.Substring(i, tmp - i + 1);
                            text = text.ReplaceFirst(originString, TranslateInputText(originString));
                            AddChatUIEquipmentLabel(TranslateInputText(originString),
                                                    obj.transform.Find("ChatUIDialogLabelSLList"), (g) =>
                            {
                                float width = m_inputText.label.font.size * length;
                                int row     = (int)((width + m_fOffect) / LINEWIDTH);

                                float labelWidth = m_inputText.label.font.CalculatePrintedSize(TranslateInputText(originString),
                                                                                               true, UIFont.SymbolStyle.None).x *m_inputText.label.font.size;

                                if ((width + m_fOffect) + labelWidth > LINEWIDTH * (row + 1))
                                {
                                    m_iAddSpaceNum = (int)((LINEWIDTH * (row + 1) - (width + m_fOffect)) /
                                                           (m_inputText.label.font.CalculatePrintedSize(" ",
                                                                                                        true, UIFont.SymbolStyle.None).x *m_inputText.label.font.size));


                                    //m_fOffect += m_inputText.label.font.CalculatePrintedSize("   ", true, UIFont.SymbolStyle.None).x *
                                    //    m_inputText.label.font.size;

                                    for (int j = 0; j < m_iAddSpaceNum; ++j)
                                    {
                                        text = text.Insert(i + j, " ");
                                    }

                                    width += (m_iAddSpaceNum * m_inputText.label.font.CalculatePrintedSize(" ",
                                                                                                           true, UIFont.SymbolStyle.None).x *m_inputText.label.font.size);

                                    m_fOffect += (LINEWIDTH * (row + 1) - (width + m_fOffect));

                                    width += m_fOffect;
                                }
                                else
                                {
                                    //width = width + m_fOffect - m_iAddSpaceNum * (m_inputText.label.font.CalculatePrintedSize(" ", true, UIFont.SymbolStyle.None).x *
                                    //  m_inputText.label.font.size);
                                    width += m_fOffect;
                                }
                                //else
                                //{
                                //   width += m_fOffect;
                                //}

                                //g.transform.localPosition = new Vector3(obj.transform.localPosition.x +
                                // width % 750,
                                //     obj.transform.localPosition.y - (int)(width / 750) *
                                // 35, obj.transform.localPosition.z);

                                //g.transform.localPosition = new Vector3(obj.transform.localPosition.x +
                                //m_inputText.label.font.size * length % 750,
                                //    obj.transform.localPosition.y - (int)(m_inputText.label.font.size * length / 750) *
                                //m_inputText.label.font.size, obj.transform.localPosition.z);

                                //g.transform.GetComponentsInChildren<ChatUIEquipmentGrid>(true)[0].LogicText = originString;


                                //g.transform.localPosition = new Vector3(obj.transform.localPosition.x +
                                //     width % LINEWIDTH,
                                //    obj.transform.localPosition.y - (int)(width / LINEWIDTH) * m_inputText.label.font.size, obj.transform.localPosition.z);//这里改成0 - ...

                                g.transform.localPosition = new Vector3(obj.transform.localPosition.x +
                                                                        width % LINEWIDTH,
                                                                        0 - (int)(width / LINEWIDTH) * m_inputText.label.font.size, obj.transform.localPosition.z);

                                g.transform.GetComponentsInChildren <ChatUIEquipmentGrid>(true)[0].LogicText = originString;
                            });
                            break;
                        }

                        ++tmp;
                    }
                }
                else if (text[i] == '<' && text.Substring(i).Length >= 6 && text.Substring(i, 6) == "<face=")
                {
                    int tmp = i + 7;

                    while (tmp < text.Length)
                    {
                        if (text[tmp] == '>')
                        {
                            float length = m_inputText.label.font.CalculatePrintedSize(text.Substring(0, i), true, UIFont.SymbolStyle.None).x;

                            string originString = text.Substring(i, tmp - i + 1);
                            text = text.ReplaceFirst(originString, /*TranslateInputText(originString)*/ " ");
                            AddChatUIFaceLabel(TranslateInputText(originString),
                                               obj.transform.Find("ChatUIDialogLabelSLList"), (g) =>
                            {
                                float width = m_inputText.label.font.size * length;
                                int row     = (int)((width + m_fOffect) / LINEWIDTH);

                                if ((width + m_fOffect) + FONTSIZE > LINEWIDTH * (row + 1))
                                {
                                    m_fOffect += (LINEWIDTH * (row + 1) - (width + m_fOffect));
                                    width      = width + m_fOffect;
                                }
                                else
                                {
                                    width += m_fOffect;
                                }

                                g.transform.localPosition = new Vector3(obj.transform.localPosition.x +
                                                                        width % LINEWIDTH,
                                                                        obj.transform.localPosition.y - (int)(width / LINEWIDTH) *
                                                                        FONTSIZE, obj.transform.localPosition.z);
                            });
                            break;
                        }

                        ++tmp;
                    }
                }
                else
                {
                    float length = m_inputText.label.font.CalculatePrintedSize(text.Substring(0, i), true, UIFont.SymbolStyle.None).x;

                    float width      = m_inputText.label.font.size * length;
                    int row          = (int)((width + m_fOffect) / LINEWIDTH);
                    float labelWidth = m_inputText.label.font.CalculatePrintedSize(text[i].ToString(),
                                                                                   true, UIFont.SymbolStyle.None).x *m_inputText.label.font.size;

                    if ((width + m_fOffect) + labelWidth > LINEWIDTH * (row + 1))
                    {
                        // m_iAddSpaceNum = (int)((LINEWIDTH * (row + 1) - (width + m_fOffect)) /
                        //(m_inputText.label.font.CalculatePrintedSize(" ",
                        //         true, UIFont.SymbolStyle.None).x * m_inputText.label.font.size));
                        m_fOffect += (LINEWIDTH * (row + 1) - (width + m_fOffect));
                        //width += m_fOffect;
                    }
                    //else
                    //{
                    //    width += m_fOffect;
                    //}*/
                }
            }

            lblChatUIDialogLabelText.text            = text;
            lblChatUIDialogLabelText.supportEncoding = true;

            obj.transform.localPosition = new Vector3(0, 0 - FONTSIZE * m_iLineNum - FONTSPACE * m_iSpaceNum, 0);


            obj.transform.GetComponentsInChildren <BoxCollider>(true)[0].size =
                new Vector3(obj.transform.GetComponentsInChildren <BoxCollider>(true)[0].size.x,
                            obj.transform.GetComponentsInChildren <BoxCollider>(true)[0].size.y *
                            ((int)(m_inputText.label.font.CalculatePrintedSize(text, true, UIFont.SymbolStyle.None).x *FONTSIZE / LINEWIDTH) + 1),
                            obj.transform.GetComponentsInChildren <BoxCollider>(true)[0].size.z);

            obj.transform.GetComponentsInChildren <BoxCollider>(true)[0].center =
                new Vector3(obj.transform.GetComponentsInChildren <BoxCollider>(true)[0].center.x,
                            obj.transform.GetComponentsInChildren <BoxCollider>(true)[0].center.y -
                            ((int)(m_inputText.label.font.CalculatePrintedSize(text, true, UIFont.SymbolStyle.None).x *FONTSIZE / LINEWIDTH)) * 0.5f * FONTSIZE,
                            obj.transform.GetComponentsInChildren <BoxCollider>(true)[0].center.z);

            obj.GetComponentsInChildren <CommunityUIDialogLabel>(true)[0].ID = userId;

            m_iLineNum += ((int)(m_inputText.label.font.CalculatePrintedSize(text, true, UIFont.SymbolStyle.None).x *FONTSIZE / LINEWIDTH) + 1);


            relatedCam.GetComponentsInChildren <MyDragableCamera>(true)[0].MINY = -192 - (FONTSIZE * m_iLineNum + m_iSpaceNum * FONTSPACE) + 406;

            CommunityLabelInfo info = new CommunityLabelInfo();
            info.height             = FONTSIZE * ((int)(m_inputText.label.font.CalculatePrintedSize(text, true, UIFont.SymbolStyle.None).x *FONTSIZE / LINEWIDTH) + 1);
            info.go = obj;

            m_queueChatData.Enqueue(info);

            if (m_queueChatData.Count > 50)
            {
                CommunityLabelInfo infoTmp = m_queueChatData.Dequeue();
                AssetCacheMgr.ReleaseInstance(infoTmp.go);
                //Debug.LogError(infoTmp.height);
                relatedCam.GetComponentsInChildren <MyDragableCamera>(true)[0].MAXY -= (infoTmp.height + FONTSPACE);
            }

            m_iSpaceNum++;

            //if (text.Length > 7 && (text[0] == '[' && text[7] == ']'))
            //{
            //    obj.transform.GetComponentsInChildren<BoxCollider>(true)[0].size =
            //   new Vector3((text.Length - 8 - 2) * 22 + 14, 22, 0);

            //    obj.transform.GetComponentsInChildren<BoxCollider>(true)[0].center =
            //      new Vector3(obj.transform.GetComponentsInChildren<BoxCollider>(true)[0].size.x * 0.5f, 0f, 0f);

            //    m_lblInputText.text += text.Substring(8);


            //}
            //else
            //{
            //    obj.transform.GetComponentsInChildren<BoxCollider>(true)[0].size =
            //  new Vector3((text.Length - 2) * 22 + 14, 22, 0);

            //    m_lblInputText.text += text;
            //}

            switch (channel)
            {
            case ChannelId.WORLD:
            case ChannelId.SYSTEM:
                m_iLineNumWorld  = m_iLineNum;
                m_iSpaceNumWorld = m_iSpaceNum;
                break;

            case ChannelId.UNION:
                m_iLineNumTong  = m_iLineNum;
                m_iSpaceNumTong = m_iSpaceNum;
                break;

            case ChannelId.PERSONAL:
                m_iLineNumPrivate  = m_iLineNum;
                m_iSpaceNumPrivate = m_iSpaceNum;
                break;
            }

            if ((m_iLineNum * FONTSIZE + m_iSpaceNum * FONTSPACE) > 428)
            {
                float offect = ((int)(m_inputText.label.font.CalculatePrintedSize(text, true, UIFont.SymbolStyle.None).x *FONTSIZE / LINEWIDTH) + 1) * FONTSIZE + FONTSPACE;
                relatedCam.transform.localPosition = new Vector3(relatedCam.transform.localPosition.x,
                                                                 relatedCam.transform.localPosition.y - offect, relatedCam.transform.localPosition.z);
            }

            m_listChatUIDialogText.Add(obj);
        });


        m_fOffect      = 0;
        m_iAddSpaceNum = 0;
    }
    /// <summary>
    /// 添加一条聊天信息
    /// </summary>
    /// <param name="text">聊天信息显示的内容</param>
    /// <param name="channel">聊天信息放至的频道</param>
    /// <param name="userId">发送玩家的ID</param>
    /// <param name="channelIcon">聊天信息发送的频道,用于显示频道图标</param>
    /// <param name="LvAndNameString">聊天信息的人名,用于计算下划线的长度</param>
    /// <param name="underLineColor">人名下划线颜色</param>
    /// <param name="lineOffsetX">人名下划线偏移,自己向别的玩家的私聊信息需处理</param>    
    public void AddChatUIDialogText(string text, ChannelId channel, ulong userId,
        ChannelId channelIcon, string LvAndNameString = "", string underLineColor = "13FFD5", int lineOffsetX = 60)
    {
        string name = "WorldChannelDialogLabelList";

        int m_iLineNum = 0;
        int m_iSpaceNum = 0;
        Camera relatedCam = m_camWorldChannelCamera;


        AssetCacheMgr.GetUIInstance("ChatUIDialogLabel.prefab", (prefab, id, go) =>
        {
            GameObject obj = (GameObject)go;

            
            UILabel lblChatUIDialogLabelText = obj.transform.FindChild("ChatUIDialogLabelText").GetComponentsInChildren<UILabel>(true)[0];
            lblChatUIDialogLabelText.effectStyle = UILabel.Effect.Outline;

            UISprite spChatUIDialogLabelChannel = obj.transform.FindChild("ChatUIDialogLabelChannel").GetComponentsInChildren<UISprite>(true)[0];
            SetChatUIDialogLabelChannel(channelIcon, spChatUIDialogLabelChannel);

            // 设置下划线
            UILabel lblChatUIDialogLabelUnderLine = obj.transform.FindChild("ChatUIDialogLabelUnderLine").GetComponentsInChildren<UILabel>(true)[0];
            float totalUnderline = m_inputText.label.font.CalculatePrintedSize(LvAndNameString, true, UIFont.SymbolStyle.None).x;
            float oneUnderLine = m_inputText.label.font.CalculatePrintedSize("_", true, UIFont.SymbolStyle.None).x;
            int underLineCount = (int)(totalUnderline / oneUnderLine);

            lblChatUIDialogLabelUnderLine.text = "";
            for (int i = 0; i < underLineCount; i++)
            {
                lblChatUIDialogLabelUnderLine.text += "_";
            }

            // 设置下划线颜色
            lblChatUIDialogLabelUnderLine.text = string.Concat("[", underLineColor, "]", lblChatUIDialogLabelUnderLine.text, "[-]");

            switch (channel)
            {
                case ChannelId.WORLD:
                    name = "WorldChannelDialogLabelList";
                    m_iLineNum = m_iLineNumWorld;
                    m_iSpaceNum = m_iSpaceNumWorld;
                    relatedCam = m_camWorldChannelCamera;
                    lblChatUIDialogLabelText.effectColor = new Color32(32, 19, 14, 255);
                    break;

                case ChannelId.UNION:
                    name = "TongChannelDialogLabelList";
                    m_iLineNum = m_iLineNumTong;
                    m_iSpaceNum = m_iSpaceNumTong;
                    relatedCam = m_camTongChannelCamera;
                    lblChatUIDialogLabelText.effectColor = new Color32(0, 0, 0, 255);
                    break;

                case ChannelId.PERSONAL:
                    name = "PrivateChannelDialogLabelList";
                    m_iLineNum = m_iLineNumPrivate;
                    m_iSpaceNum = m_iSpaceNumPrivate;
                    relatedCam = m_camPrivateChannelCamera;
                    lblChatUIDialogLabelText.effectColor = new Color32(13, 0, 16, 255);
                    lblChatUIDialogLabelUnderLine.transform.localPosition = new Vector3(lineOffsetX,
                        lblChatUIDialogLabelUnderLine.transform.localPosition.y,
                        lblChatUIDialogLabelUnderLine.transform.localPosition.z);
                    break;

                case ChannelId.SYSTEM:
                    name = "WorldChannelDialogLabelList";
                    m_iLineNum = m_iLineNumWorld;
                    m_iSpaceNum = m_iSpaceNumWorld;
                    relatedCam = m_camWorldChannelCamera;
                    lblChatUIDialogLabelText.effectColor = new Color32(0, 0, 0, 255);
                    break;
            }
            
            obj.SetActive(true);
            obj.transform.parent = m_myTransform.FindChild(m_widgetToFullName[name]);
            obj.transform.parent.localScale = new Vector3(0.0008f, 0.0008f, 1);
            obj.transform.localPosition = Vector3.zero;
            obj.transform.localScale = new Vector3(1, 1, 1);
            obj.transform.GetComponentsInChildren<MyDragCamera>(true)[0].RelatedCamera = relatedCam;

            string strTmp = text;

            for (int i = 0; i < text.Length; ++i)
            {
                if (text[i] == '<' && text.Substring(i).Length >= 6 && text.Substring(i, 6) == "<info=")
                {
                    int tmp = i + 7;

                    while (tmp < text.Length)
                    {
                        if (text[tmp] == '>')
                        {
                            float length = m_inputText.label.font.CalculatePrintedSize(text.Substring(0, i), true, UIFont.SymbolStyle.None).x;

                            string originString = text.Substring(i, tmp - i + 1);
                            text = text.ReplaceFirst(originString, TranslateInputText(originString));
                            AddChatUIEquipmentLabel(TranslateInputText(originString),
                                obj.transform.FindChild("ChatUIDialogLabelSLList"), (g) =>
                                {
                                    float width = m_inputText.label.font.size * length;
                                    int row = (int)((width + m_fOffect) / LINEWIDTH);

                                    float labelWidth = m_inputText.label.font.CalculatePrintedSize(TranslateInputText(originString),
                                        true, UIFont.SymbolStyle.None).x * m_inputText.label.font.size;

                                    if ((width + m_fOffect) + labelWidth > LINEWIDTH * (row + 1))
                                    {
                                        m_iAddSpaceNum = (int)((LINEWIDTH * (row + 1) - (width + m_fOffect)) /
                                        (m_inputText.label.font.CalculatePrintedSize(" ",
                                        true, UIFont.SymbolStyle.None).x * m_inputText.label.font.size));


                                        //m_fOffect += m_inputText.label.font.CalculatePrintedSize("   ", true, UIFont.SymbolStyle.None).x * 
                                        //    m_inputText.label.font.size;

                                        for (int j = 0; j < m_iAddSpaceNum; ++j)
                                        {
                                            text = text.Insert(i + j, " ");
                                        }

                                        width += (m_iAddSpaceNum * m_inputText.label.font.CalculatePrintedSize(" ",
                                            true, UIFont.SymbolStyle.None).x * m_inputText.label.font.size);

                                        m_fOffect += (LINEWIDTH * (row + 1) - (width + m_fOffect));

                                        width += m_fOffect;
                                    }
                                    else
                                    {
                                        //width = width + m_fOffect - m_iAddSpaceNum * (m_inputText.label.font.CalculatePrintedSize(" ", true, UIFont.SymbolStyle.None).x *
                                        //  m_inputText.label.font.size);
                                        width += m_fOffect;
                                    }
                                    //else
                                    //{
                                    //   width += m_fOffect;
                                    //}

                                    //g.transform.localPosition = new Vector3(obj.transform.localPosition.x +
                                    // width % 750,
                                    //     obj.transform.localPosition.y - (int)(width / 750) *
                                    // 35, obj.transform.localPosition.z);

                                    //g.transform.localPosition = new Vector3(obj.transform.localPosition.x +
                                    //m_inputText.label.font.size * length % 750,
                                    //    obj.transform.localPosition.y - (int)(m_inputText.label.font.size * length / 750) *
                                    //m_inputText.label.font.size, obj.transform.localPosition.z);

                                    //g.transform.GetComponentsInChildren<ChatUIEquipmentGrid>(true)[0].LogicText = originString;


                                    //g.transform.localPosition = new Vector3(obj.transform.localPosition.x +
                                    //     width % LINEWIDTH,
                                    //    obj.transform.localPosition.y - (int)(width / LINEWIDTH) * m_inputText.label.font.size, obj.transform.localPosition.z);//这里改成0 - ...

                                    g.transform.localPosition = new Vector3(obj.transform.localPosition.x +
                                        width % LINEWIDTH,
                                       0 - (int)(width / LINEWIDTH) * m_inputText.label.font.size, obj.transform.localPosition.z);

                                    g.transform.GetComponentsInChildren<ChatUIEquipmentGrid>(true)[0].LogicText = originString;

                                });
                            break;
                        }

                        ++tmp;
                    }
                }
                else if (text[i] == '<' && text.Substring(i).Length >= 6 && text.Substring(i, 6) == "<face=")
                {
                    int tmp = i + 7;

                    while (tmp < text.Length)
                    {
                        if (text[tmp] == '>')
                        {
                            float length = m_inputText.label.font.CalculatePrintedSize(text.Substring(0, i), true, UIFont.SymbolStyle.None).x;

                            string originString = text.Substring(i, tmp - i + 1);
                            text = text.ReplaceFirst(originString, /*TranslateInputText(originString)*/" ");
                            AddChatUIFaceLabel(TranslateInputText(originString),
                                obj.transform.FindChild("ChatUIDialogLabelSLList"), (g) =>
                                {
                                    float width = m_inputText.label.font.size * length;
                                    int row = (int)((width + m_fOffect) / LINEWIDTH);

                                    if ((width + m_fOffect) + FONTSIZE > LINEWIDTH * (row + 1))
                                    {
                                        m_fOffect += (LINEWIDTH * (row + 1) - (width + m_fOffect));
                                        width = width + m_fOffect;
                                    }
                                    else
                                    {
                                        width += m_fOffect;
                                    }

                                    g.transform.localPosition = new Vector3(obj.transform.localPosition.x +
                                     width % LINEWIDTH,
                                         obj.transform.localPosition.y - (int)(width / LINEWIDTH) *
                                     FONTSIZE, obj.transform.localPosition.z);

                                });
                            break;
                        }

                        ++tmp;
                    }
                }
                else
                {
                    float length = m_inputText.label.font.CalculatePrintedSize(text.Substring(0, i), true, UIFont.SymbolStyle.None).x;

                    float width = m_inputText.label.font.size * length;
                    int row = (int)((width + m_fOffect) / LINEWIDTH);
                    float labelWidth = m_inputText.label.font.CalculatePrintedSize(text[i].ToString(),
                           true, UIFont.SymbolStyle.None).x * m_inputText.label.font.size;

                    if ((width + m_fOffect) + labelWidth > LINEWIDTH * (row + 1))
                    {
                        // m_iAddSpaceNum = (int)((LINEWIDTH * (row + 1) - (width + m_fOffect)) /
                        //(m_inputText.label.font.CalculatePrintedSize(" ",
                        //         true, UIFont.SymbolStyle.None).x * m_inputText.label.font.size));
                        m_fOffect += (LINEWIDTH * (row + 1) - (width + m_fOffect));
                        //width += m_fOffect;
                    }
                    //else
                    //{
                    //    width += m_fOffect;
                    //}*/
                }
            }

            lblChatUIDialogLabelText.text = text;
            lblChatUIDialogLabelText.supportEncoding = true;

            obj.transform.localPosition = new Vector3(0, 0 - FONTSIZE * m_iLineNum - FONTSPACE * m_iSpaceNum, 0);


            obj.transform.GetComponentsInChildren<BoxCollider>(true)[0].size =
                new Vector3(obj.transform.GetComponentsInChildren<BoxCollider>(true)[0].size.x,
                    obj.transform.GetComponentsInChildren<BoxCollider>(true)[0].size.y *
                    ((int)(m_inputText.label.font.CalculatePrintedSize(text, true, UIFont.SymbolStyle.None).x * FONTSIZE / LINEWIDTH) + 1),
                    obj.transform.GetComponentsInChildren<BoxCollider>(true)[0].size.z);

            obj.transform.GetComponentsInChildren<BoxCollider>(true)[0].center =
                new Vector3(obj.transform.GetComponentsInChildren<BoxCollider>(true)[0].center.x,
                    obj.transform.GetComponentsInChildren<BoxCollider>(true)[0].center.y -
                    ((int)(m_inputText.label.font.CalculatePrintedSize(text, true, UIFont.SymbolStyle.None).x * FONTSIZE / LINEWIDTH)) * 0.5f * FONTSIZE,
                    obj.transform.GetComponentsInChildren<BoxCollider>(true)[0].center.z);

            obj.GetComponentsInChildren<CommunityUIDialogLabel>(true)[0].ID = userId;

            m_iLineNum += ((int)(m_inputText.label.font.CalculatePrintedSize(text, true, UIFont.SymbolStyle.None).x * FONTSIZE / LINEWIDTH) + 1);


            relatedCam.GetComponentsInChildren<MyDragableCamera>(true)[0].MINY = -192 - (FONTSIZE * m_iLineNum + m_iSpaceNum * FONTSPACE) + 406;

            CommunityLabelInfo info = new CommunityLabelInfo();
            info.height = FONTSIZE * ((int)(m_inputText.label.font.CalculatePrintedSize(text, true, UIFont.SymbolStyle.None).x * FONTSIZE / LINEWIDTH) + 1);
            info.go = obj;

            m_queueChatData.Enqueue(info);

            if (m_queueChatData.Count > 50)
            {
                CommunityLabelInfo infoTmp = m_queueChatData.Dequeue();
                AssetCacheMgr.ReleaseInstance(infoTmp.go);
                //Debug.LogError(infoTmp.height);
                relatedCam.GetComponentsInChildren<MyDragableCamera>(true)[0].MAXY -= (infoTmp.height + FONTSPACE);
            }

            m_iSpaceNum++;

            //if (text.Length > 7 && (text[0] == '[' && text[7] == ']'))
            //{
            //    obj.transform.GetComponentsInChildren<BoxCollider>(true)[0].size =
            //   new Vector3((text.Length - 8 - 2) * 22 + 14, 22, 0);

            //    obj.transform.GetComponentsInChildren<BoxCollider>(true)[0].center =
            //      new Vector3(obj.transform.GetComponentsInChildren<BoxCollider>(true)[0].size.x * 0.5f, 0f, 0f);

            //    m_lblInputText.text += text.Substring(8);


            //}
            //else
            //{
            //    obj.transform.GetComponentsInChildren<BoxCollider>(true)[0].size =
            //  new Vector3((text.Length - 2) * 22 + 14, 22, 0);

            //    m_lblInputText.text += text;
            //}

            switch (channel)
            {
                case ChannelId.WORLD:
                case ChannelId.SYSTEM:
                    m_iLineNumWorld = m_iLineNum;
                    m_iSpaceNumWorld = m_iSpaceNum;
                    break;

                case ChannelId.UNION:
                    m_iLineNumTong = m_iLineNum;
                    m_iSpaceNumTong = m_iSpaceNum;
                    break;

                case ChannelId.PERSONAL:
                    m_iLineNumPrivate = m_iLineNum;
                    m_iSpaceNumPrivate = m_iSpaceNum;
                    break;
            }

            if ((m_iLineNum * FONTSIZE + m_iSpaceNum * FONTSPACE) > 428)
            {
                float offect = ((int)(m_inputText.label.font.CalculatePrintedSize(text, true, UIFont.SymbolStyle.None).x * FONTSIZE / LINEWIDTH) + 1) * FONTSIZE + FONTSPACE;
                relatedCam.transform.localPosition = new Vector3(relatedCam.transform.localPosition.x,
                    relatedCam.transform.localPosition.y - offect, relatedCam.transform.localPosition.z);
            }

            m_listChatUIDialogText.Add(obj);
        });


        m_fOffect = 0;
        m_iAddSpaceNum = 0;
    }