少年修仙传客户端代码仓库
client_linchunjie
2018-11-06 3be2da602fb3c0d3f29889d27ab670a159f9f11b
4398 【1.2】聊天气泡框
3个文件已修改
82 ■■■■ 已修改文件
System/Chat/ChatBubbleBehaviour.cs 80 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatMineVoiceCell.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatOtherVoiceCell.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/Chat/ChatBubbleBehaviour.cs
@@ -16,6 +16,9 @@
        [SerializeField] Image m_BubbleIcon;
        [SerializeField] bool left = false;
        [SerializeField] bool m_PreferredWidth = false;
        [SerializeField] RectTransform m_ContainerVoice;
        const float space = 5.0f;
        private int bubbleId = 0;
@@ -112,16 +115,67 @@
            {
                return;
            }
            bool nullContent = string.IsNullOrEmpty(m_Target.text);
            var targetRect = m_Target.rectTransform;
            var sizeDelta = targetRect.sizeDelta;
            var width = m_PreferredWidth || !Application.isPlaying ? m_Target.preferredWidth : sizeDelta.x;
            if (nullContent)
            {
                width = 0f;
            }
            var height = sizeDelta.y;
            if (nullContent)
            {
                height = 0;
            }
            if (m_ContainerVoice != null)
            {
                width = Mathf.Max(m_ContainerVoice.sizeDelta.x, width);
                height += m_ContainerVoice.sizeDelta.y;
                if (!nullContent)
                {
                    height += space;
                }
            }
            sizeDelta.x = width + m_Padding.left + m_Padding.right;
            sizeDelta.y = sizeDelta.y + m_Padding.top + m_Padding.bottom;
            sizeDelta.y = height + m_Padding.top + m_Padding.bottom;
            if (sizeDelta != rect.sizeDelta)
            {
                rect.sizeDelta = sizeDelta;
            }
            SetAnchor(m_Target.rectTransform);
            if (m_ContainerVoice != null)
            {
                SetAnchor(m_ContainerVoice);
            }
            float top = padding.top;
            Vector2 position = Vector2.zero;
            position.x = left ? padding.left : -padding.right;
            if (m_ContainerVoice != null)
            {
                position.y = -top;
                if (m_ContainerVoice.anchoredPosition != position)
                {
                    m_ContainerVoice.anchoredPosition = position;
                }
                top = top + m_ContainerVoice.sizeDelta.y;
                top += space;
            }
            position.y = -top;
            if (targetRect.anchoredPosition != position)
            {
                targetRect.anchoredPosition = position;
            }
        }
        void SetAnchor(RectTransform targetRect)
        {
            if (!left)
            {
                if (targetRect.anchorMin != Vector2.one)
@@ -152,14 +206,6 @@
                    targetRect.pivot = Vector2.up;
                }
            }
            var position = targetRect.anchoredPosition;
            position.x = left ? padding.left : -padding.right;
            position.y = -padding.top;
            if (targetRect.anchoredPosition != position)
            {
                targetRect.anchoredPosition = position;
            }
        }
        public float GetBubbleHeight(string content, ArrayList list)
@@ -169,7 +215,21 @@
                (m_Target as RichText).SetExtenalData(list);
            }
            m_Target.text = content;
            return m_Target.preferredHeight + padding.top + padding.bottom;
            var height = m_Target.preferredHeight;
            bool nullContent = string.IsNullOrEmpty(content);
            if (nullContent)
            {
                height = 0f;
            }
            if (m_ContainerVoice != null)
            {
                height += m_ContainerVoice.sizeDelta.y;
                if (!nullContent)
                {
                    height += space;
                }
            }
            return height + padding.top + padding.bottom;
        }
    }
}
System/Chat/ChatMineVoiceCell.cs
@@ -34,7 +34,6 @@
            }
            m_ChatBubble.DisplayContent(_data.content);
            m_ChatBubble.DisplayBubble((int)PlayerDatas.Instance.baseData.bubbleId);
            m_ChatBubble.gameObject.SetActive(!string.IsNullOrEmpty(_data.content));
            m_ChatIcon.SetSprite(GeneralDefine.GetJobHeadPortrait(_data.job, 0));
            m_PlayerName.text = _data.name;
System/Chat/ChatOtherVoiceCell.cs
@@ -40,7 +40,6 @@
            });
            m_ChatBubble.DisplayContent(_data.content, true);
            m_ChatBubble.DisplayBubble(_data.bubbleId);
            m_ChatBubble.gameObject.SetActive(!string.IsNullOrEmpty(_data.content));
            m_ChatIcon.SetSprite(GeneralDefine.GetJobHeadPortrait(_data.job, 0));
            m_PlayerName.text = _data.name;
            m_ChatTime.text = _data.createTime.ToString("yyyy-MM-dd HH:mm");