Exemplo n.º 1
0
        public override void SetChatContent(string contentText)
        {
            mChatMsgText.rectTransform.sizeDelta = MaxChatMsgTextWidth;
            mChatMsgText.text = xc.GoodsHelper.ReplaceGoodsColor_whiteBkg(contentText);

            float width = mChatMsgText.GetPreferredWidth(mScaleFactor);

            width = Mathf.Min(width, MaxChatMsgTextWidth.x);

            var size = MaxChatMsgTextWidth;

            size.x = width;
            mChatMsgText.rectTransform.sizeDelta = size;

            // 调整Item大小
            ContentSizeFitByTarget contentFit = mChatMsgText.transform.GetComponent <ContentSizeFitByTarget>();

            if (null != contentFit)
            {
                contentFit.SizeFit(mScaleFactor);
            }

            if (mWineIcon != null)
            {
                mWineIcon.GetComponent <RectTransform>().anchoredPosition3D = new Vector3(size.x + 50, -mChatMsgText.preferredHeight - 25, 0);
            }
        }
Exemplo n.º 2
0
        public override void SetVoiceChatContent(string contentText)
        {
            mVoiceChatMsgText.text = contentText;

            // 调整layout的padding
            ChatVoiceLayoutAdapt adapt = mVoiceLayoutTrans.transform.GetComponent <ChatVoiceLayoutAdapt>();

            if (null != adapt)
            {
                adapt.SetLayoutPadding();
            }

            // 调整最大宽度
            MaxLayoutElement maxElement = mVoiceChatMsgText.transform.GetComponent <MaxLayoutElement>();

            if (null != maxElement)
            {
                maxElement.SetMaxWidth();
            }

            LayoutRebuilder.ForceRebuildLayoutImmediate(mVoiceLayoutTrans);

            // 调整Item大小
            ContentSizeFitByTarget contentFit = mVoiceChatMsgText.transform.GetComponent <ContentSizeFitByTarget>();

            if (null != contentFit)
            {
                contentFit.SizeFit(mScaleFactor);
            }
        }
Exemplo n.º 3
0
        public override void SetSystemChannelContent(string msg)
        {
            mContentText.rectTransform.sizeDelta = MaxChatMsgTextWidth;
            mContentText.text = xc.GoodsHelper.ReplaceGoodsColor_whiteBkg(msg);

            float width = mContentText.GetPreferredWidth(mScaleFactor);

            width = Mathf.Min(width, MaxChatMsgTextWidth.x);

            var size = MaxChatMsgTextWidth;

            size.x = width;
            mContentText.rectTransform.sizeDelta = size;

            // 调整Item大小
            ContentSizeFitByTarget contentFit = mContentText.transform.GetComponent <ContentSizeFitByTarget>();

            if (null != contentFit)
            {
                contentFit.SizeFit(mScaleFactor);
            }
        }