| | |
| | | Refresh(); |
| | | } |
| | | |
| | | public void DisplayContent(string content, bool _left = false) |
| | | public void DisplayContent(string content) |
| | | { |
| | | if (m_Target == null) |
| | | { |
| | | return; |
| | | } |
| | | left = _left; |
| | | m_PreferredWidth = true; |
| | | var richText = m_Target as RichText; |
| | | if (richText != null && !left) |
| | | { |
| | | richText.AutoNewLine = false; |
| | | } |
| | | m_Target.text = content; |
| | | |
| | | |
| | | if (richText != null) |
| | | { |
| | | richText.AutoNewLine = true; |
| | |
| | | rect.sizeDelta = sizeDelta; |
| | | } |
| | | |
| | | SetAnchor(m_Target.rectTransform); |
| | | if (m_Target.rectTransform.anchorMin != Vector2.up) |
| | | { |
| | | m_Target.rectTransform.anchorMin = Vector2.up; |
| | | } |
| | | if (m_Target.rectTransform.anchorMax != Vector2.up) |
| | | { |
| | | m_Target.rectTransform.anchorMax = Vector2.up; |
| | | } |
| | | if (m_Target.rectTransform.pivot != Vector2.up) |
| | | { |
| | | m_Target.rectTransform.pivot = Vector2.up; |
| | | } |
| | | |
| | | float top = padding.top; |
| | | Vector2 position = Vector2.zero; |
| | | position.x = left ? padding.left : -padding.right; |
| | | position.x = padding.left; |
| | | |
| | | position.y = -top; |
| | | if (targetRect.anchoredPosition != position) |
| | | { |
| | | targetRect.anchoredPosition = position; |
| | | } |
| | | } |
| | | |
| | | void SetAnchor(RectTransform targetRect) |
| | | { |
| | | if (!left) |
| | | { |
| | | if (targetRect.anchorMin != Vector2.one) |
| | | { |
| | | targetRect.anchorMin = Vector2.one; |
| | | } |
| | | if (targetRect.anchorMax != Vector2.one) |
| | | { |
| | | targetRect.anchorMax = Vector2.one; |
| | | } |
| | | if (targetRect.pivot != Vector2.one) |
| | | { |
| | | targetRect.pivot = Vector2.one; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if (targetRect.anchorMin != Vector2.up) |
| | | { |
| | | targetRect.anchorMin = Vector2.up; |
| | | } |
| | | if (targetRect.anchorMax != Vector2.up) |
| | | { |
| | | targetRect.anchorMax = Vector2.up; |
| | | } |
| | | if (targetRect.pivot != Vector2.up) |
| | | { |
| | | targetRect.pivot = Vector2.up; |
| | | } |
| | | } |
| | | } |
| | | |