Browse Source

Merge pull request #177 from FungusGames/force-rich-text

Fixed Markup text visible if rich text not enabled #176
master
Chris Gregan 10 years ago
parent
commit
43bcc3ad11
  1. 24
      Assets/Fungus/UI/Scripts/Writer.cs
  2. 1163
      Assets/Tests/UI/TextTests.unity

24
Assets/Fungus/UI/Scripts/Writer.cs

@ -49,6 +49,9 @@ namespace Fungus
[Tooltip("Write one word at a time rather one character at a time")] [Tooltip("Write one word at a time rather one character at a time")]
public bool writeWholeWords = false; public bool writeWholeWords = false;
[Tooltip("Force the target text object to use Rich Text mode so text color and alpha appears correctly")]
public bool forceRichText = true;
/** /**
* This property is true when the writer is waiting for user input to continue * This property is true when the writer is waiting for user input to continue
*/ */
@ -134,6 +137,24 @@ namespace Fungus
} }
} }
protected virtual void Start()
{
if (forceRichText)
{
if (textUI != null)
{
textUI.supportRichText = true;
}
// Input Field does not support rich text
if (textMesh != null)
{
textMesh.richText = true;
}
}
}
public virtual bool HasTextObject() public virtual bool HasTextObject()
{ {
return (textUI != null || inputField != null || textMesh != null); return (textUI != null || inputField != null || textMesh != null);
@ -555,7 +576,8 @@ namespace Fungus
string hiddenColor = String.Format("#{0:X2}{1:X2}{2:X2}{3:X2}", c.r, c.g, c.b, c.a); string hiddenColor = String.Format("#{0:X2}{1:X2}{2:X2}{3:X2}", c.r, c.g, c.b, c.a);
// Make right hand side text hidden // Make right hand side text hidden
if (rightText.Length > 0) if (SupportsRichText() &&
rightText.Length > 0)
{ {
tempText += "<color=" + hiddenColor + ">" + rightText + "</color>"; tempText += "<color=" + hiddenColor + ">" + rightText + "</color>";
} }

1163
Assets/Tests/UI/TextTests.unity

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save