public virtual PUTMPro AddTextWithOptions(PUGameObject container, string content, string fontPath, Color color, float fontScale, string style, TMPro.TextAlignmentOptions alignment) { if (currentY != 0) { currentY -= paragraphSpacing (); } float maxWidth = container.size.Value.x - (padding.left + padding.right); PUTMPro text = new PUTMPro (); text.SetFrame (padding.left, currentY - padding.top, maxWidth, 0, 0, 1, "top,left"); text.font = fontPath; text.fontColor = color; text.fontStyle = style; text.fontSize = (int)(DefaultFontSize()*fontScale); text.sizeToFit = true; text.alignment = alignment; text.value = content; if (urlLinks.Count > 0) { string[] linkURLs = urlLinks.ToArray(); text.OnLinkClickAction = (linkText,linkIdx) => { OpenLink(linkURLs[linkIdx]); }; urlLinks.Clear(); } text.LoadIntoPUGameObject (container); Vector2 size = text.CalculateTextSize (content, maxWidth); text.rectTransform.sizeDelta = size; currentY -= text.rectTransform.sizeDelta.y + padding.bottom; return text; }
public override void Create_OL_LI(PUGameObject container, string content) { if (listCounts.Peek() != 0) { currentY += DefaultFontSize() * 0.5f; } float oldY = currentY; padding.left += DefaultFontSize() * 2.0f; Create_P(container, content); padding.left -= DefaultFontSize() * 2.0f; PUTMPro text = new PUTMPro(); text.SetFrame(padding.left, currentY - padding.top, DefaultFontSize() * 1.5f, (oldY - currentY) - DefaultFontSize(), 0, 0, "top,left"); text.font = DefaultFont(); text.value = string.Format("{0}.", listCounts.Peek() + 1); text.fontColor = textColor(); text.fontStyle = "Bold"; text.fontSize = (int)(DefaultFontSize()); text.sizeToFit = true; text.alignment = TMPro.TextAlignmentOptions.TopRight; text.enableWordWrapping = false; text.LoadIntoPUGameObject(container); text.textGUI.overflowMode = TMPro.TextOverflowModes.Overflow; listCounts.Push(listCounts.Pop() + 1); }
public virtual PUTMPro AddTextWithOptions(PUGameObject container, string content, string fontPath, Color color, float fontScale, string style, TMPro.TextAlignmentOptions alignment) { if (currentY != 0) { currentY -= paragraphSpacing(); } float maxWidth = container.size.Value.x - (padding.left + padding.right); PUTMPro text = new PUTMPro(); text.SetFrame(padding.left, currentY - padding.top, maxWidth, 0, 0, 1, "top,left"); text.font = fontPath; text.fontColor = color; text.fontStyle = style; text.fontSize = (int)(DefaultFontSize() * fontScale); text.sizeToFit = true; text.alignment = alignment; text.value = content; if (urlLinks.Count > 0) { string[] linkURLs = urlLinks.ToArray(); text.OnLinkClickAction = (linkText, linkIdx) => { OpenLink(linkURLs[linkIdx]); }; urlLinks.Clear(); } text.LoadIntoPUGameObject(container); Vector2 size = text.CalculateTextSize(content, maxWidth); text.rectTransform.sizeDelta = size; currentY -= text.rectTransform.sizeDelta.y + padding.bottom; return(text); }
public override void Create_UL_LI(PUGameObject container, string content) { if (listCounts.Peek() != 0) { currentY += DefaultFontSize() * 0.5f; } float oldY = currentY; padding.left += DefaultFontSize() * 2.0f; Create_P(container, content); padding.left -= DefaultFontSize() * 2.0f; PUTMPro text = new PUTMPro (); text.SetFrame (padding.left, currentY - padding.top, DefaultFontSize() * 1.5f, (oldY - currentY) - DefaultFontSize(), 0, 0, "top,left"); text.font = DefaultFont(); text.value = "•"; text.fontColor = textColor(); text.fontStyle = "Bold"; text.fontSize = (int)(DefaultFontSize()); text.sizeToFit = true; text.alignment = TMPro.TextAlignmentOptions.TopRight; text.enableWordWrapping = false; text.LoadIntoPUGameObject (container); text.textGUI.OverflowMode = TMPro.TextOverflowModes.Overflow; listCounts.Push(listCounts.Pop() + 1); }