Esempio n. 1
0
        public void SetItemData(ChatMsg itemData, int itemIndex)
        {
            mIndexText.text = itemIndex.ToString();
            PersonInfo person = ChatMsgDataSourceMgr.Get.GetPersonInfo(itemData.mPersonId);

            mItemIndex = itemIndex;
            if (itemData.mMsgType == MsgTypeEnum.Str)
            {
                mMsgPic.gameObject.SetActive(false);
                mMsgText.gameObject.SetActive(true);
                mMsgText.text = itemData.mSrtMsg;
                mMsgText.GetComponent <ContentSizeFitter>().SetLayoutVertical();
                mIcon.sprite = ResManager.Get.GetSpriteByName(person.mHeadIcon);
                Vector2 size = mItemBg.GetComponent <RectTransform>().sizeDelta;
                size.x = mMsgText.GetComponent <RectTransform>().sizeDelta.x + 20;
                size.y = mMsgText.GetComponent <RectTransform>().sizeDelta.y + 20;
                mItemBg.GetComponent <RectTransform>().sizeDelta = size;
                if (person.mId == 0)
                {
                    mItemBg.color = new Color32(160, 231, 90, 255);
                    mArrow.color  = mItemBg.color;
                }
                else
                {
                    mItemBg.color = Color.white;
                    mArrow.color  = mItemBg.color;
                }
                RectTransform tf = gameObject.GetComponent <RectTransform>();
                float         y  = size.y;
                if (y < 75)
                {
                    y = 75;
                }
                tf.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, y);
            }
            else
            {
                mMsgPic.gameObject.SetActive(true);
                mMsgText.gameObject.SetActive(false);
                mMsgPic.sprite = ResManager.Get.GetSpriteByName(itemData.mPicMsgSpriteName);
                mMsgPic.SetNativeSize();
                mIcon.sprite = ResManager.Get.GetSpriteByName(person.mHeadIcon);
                Vector2 size = mItemBg.GetComponent <RectTransform>().sizeDelta;
                size.x = mMsgPic.GetComponent <RectTransform>().sizeDelta.x + 20;
                size.y = mMsgPic.GetComponent <RectTransform>().sizeDelta.y + 20;
                mItemBg.GetComponent <RectTransform>().sizeDelta = size;
                if (person.mId == 0)
                {
                    mItemBg.color = new Color32(160, 231, 90, 255);
                    mArrow.color  = mItemBg.color;
                }
                else
                {
                    mItemBg.color = Color.white;
                    mArrow.color  = mItemBg.color;
                }
                RectTransform tf = gameObject.GetComponent <RectTransform>();
                float         y  = size.y;
                if (y < 75)
                {
                    y = 75;
                }
                tf.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, y);
            }
        }
Esempio n. 2
0
        public void SetItemData(ChatMsg itemData, int itemIndex)
        {
            this.mIndexText.set_text(itemIndex.ToString());
            PersonInfo personInfo = ChatMsgDataSourceMgr.Get.GetPersonInfo(itemData.mPersonId);

            this.mItemIndex = itemIndex;
            if (itemData.mMsgType == MsgTypeEnum.Str)
            {
                ((Component)this.mMsgPic).get_gameObject().SetActive(false);
                ((Component)this.mMsgText).get_gameObject().SetActive(true);
                this.mMsgText.set_text(itemData.mSrtMsg);
                ((ContentSizeFitter)((Component)this.mMsgText).GetComponent <ContentSizeFitter>()).SetLayoutVertical();
                this.mIcon.set_sprite(ResManager.Get.GetSpriteByName(personInfo.mHeadIcon));
                Vector2 sizeDelta = ((RectTransform)((Component)this.mItemBg).GetComponent <RectTransform>()).get_sizeDelta();
                sizeDelta.x = (__Null)(((RectTransform)((Component)this.mMsgText).GetComponent <RectTransform>()).get_sizeDelta().x + 20.0);
                sizeDelta.y = (__Null)(((RectTransform)((Component)this.mMsgText).GetComponent <RectTransform>()).get_sizeDelta().y + 20.0);
                ((RectTransform)((Component)this.mItemBg).GetComponent <RectTransform>()).set_sizeDelta(sizeDelta);
                if (personInfo.mId == 0)
                {
                    ((Graphic)this.mItemBg).set_color(Color32.op_Implicit(new Color32((byte)160, (byte)231, (byte)90, byte.MaxValue)));
                    ((Graphic)this.mArrow).set_color(((Graphic)this.mItemBg).get_color());
                }
                else
                {
                    ((Graphic)this.mItemBg).set_color(Color.get_white());
                    ((Graphic)this.mArrow).set_color(((Graphic)this.mItemBg).get_color());
                }
                RectTransform component = (RectTransform)((Component)this).get_gameObject().GetComponent <RectTransform>();
                float         num       = (float)sizeDelta.y;
                if ((double)num < 75.0)
                {
                    num = 75f;
                }
                component.SetSizeWithCurrentAnchors((RectTransform.Axis) 1, num);
            }
            else
            {
                ((Component)this.mMsgPic).get_gameObject().SetActive(true);
                ((Component)this.mMsgText).get_gameObject().SetActive(false);
                this.mMsgPic.set_sprite(ResManager.Get.GetSpriteByName(itemData.mPicMsgSpriteName));
                ((Graphic)this.mMsgPic).SetNativeSize();
                this.mIcon.set_sprite(ResManager.Get.GetSpriteByName(personInfo.mHeadIcon));
                Vector2 sizeDelta = ((RectTransform)((Component)this.mItemBg).GetComponent <RectTransform>()).get_sizeDelta();
                sizeDelta.x = (__Null)(((RectTransform)((Component)this.mMsgPic).GetComponent <RectTransform>()).get_sizeDelta().x + 20.0);
                sizeDelta.y = (__Null)(((RectTransform)((Component)this.mMsgPic).GetComponent <RectTransform>()).get_sizeDelta().y + 20.0);
                ((RectTransform)((Component)this.mItemBg).GetComponent <RectTransform>()).set_sizeDelta(sizeDelta);
                if (personInfo.mId == 0)
                {
                    ((Graphic)this.mItemBg).set_color(Color32.op_Implicit(new Color32((byte)160, (byte)231, (byte)90, byte.MaxValue)));
                    ((Graphic)this.mArrow).set_color(((Graphic)this.mItemBg).get_color());
                }
                else
                {
                    ((Graphic)this.mItemBg).set_color(Color.get_white());
                    ((Graphic)this.mArrow).set_color(((Graphic)this.mItemBg).get_color());
                }
                RectTransform component = (RectTransform)((Component)this).get_gameObject().GetComponent <RectTransform>();
                float         num       = (float)sizeDelta.y;
                if ((double)num < 75.0)
                {
                    num = 75f;
                }
                component.SetSizeWithCurrentAnchors((RectTransform.Axis) 1, num);
            }
        }