| | |
| | | [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;
|
| | |
|
| | |
| | | {
|
| | | 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)
|
| | |
| | | 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)
|
| | |
| | | (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;
|
| | | }
|
| | | }
|
| | | } |