Skip to content

Instantly share code, notes, and snippets.

@anchan828
Last active December 11, 2015 15:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anchan828/4618720 to your computer and use it in GitHub Desktop.
Save anchan828/4618720 to your computer and use it in GitHub Desktop.
Small Middle Large は手動で変更する
/// <summary>
/// Unity RichText Extensions.
/// http://docs.unity3d.com/Documentation/Manual/StyledText.html
/// </summary>
namespace UnityExtensions.Text
{
public static class RichTextExtension
{
public static string Large (this string text)
{
return Size (text, 30);
}
public static string Middle (this string text)
{
return Size (text, 22);
}
public static string Small (this string text)
{
return Size (text, 18);
}
public static string Size (this string text, int size)
{
return string.Format ("<size={0}>{1}</size>", size, text);
}
public static string Bold (this string text)
{
return string.Format ("<b>{0}</b>", text);
}
public static string Italic (this string text)
{
return string.Format ("<i>{0}</i>", text);
}
public static string Color (this string text, string color = "white")
{
return string.Format ("<color={0}>{1}</color>", color, text);
}
public static string Aqua (this string text)
{
return Color (text, "aqua");
}
public static string Black (this string text)
{
return Color (text, "black");
}
public static string Blue (this string text)
{
return Color (text, "blue");
}
public static string Brown (this string text)
{
return Color (text, "brown");
}
public static string Cyan (this string text)
{
return Color (text, "cyan");
}
public static string Darkblue (this string text)
{
return Color (text, "darkblue");
}
public static string Fuchsia (this string text)
{
return Color (text, "fuchsia");
}
public static string Green (this string text)
{
return Color (text, "green");
}
public static string Grey (this string text)
{
return Color (text, "grey");
}
public static string Lightblue (this string text)
{
return Color (text, "lightblue");
}
public static string Lime (this string text)
{
return Color (text, "lime");
}
public static string Magenta (this string text)
{
return Color (text, "magenta");
}
public static string Maroon (this string text)
{
return Color (text, "maroon");
}
public static string Navy (this string text)
{
return Color (text, "navy");
}
public static string Olive (this string text)
{
return Color (text, "olive");
}
public static string Orange (this string text)
{
return Color (text, "orange");
}
public static string Purple (this string text)
{
return Color (text, "purple");
}
public static string Red (this string text)
{
return Color (text, "red");
}
public static string Silver (this string text)
{
return Color (text, "silver");
}
public static string Teal (this string text)
{
return Color (text, "teal");
}
public static string White (this string text)
{
return Color (text, "white");
}
public static string Yellow (this string text)
{
return Color (text, "yellow");
}
public static string Material (this string text, int index = 0)
{
return string.Format ("<material={0}>{1}</material>", index, text);
}
public static string Quad (int index, int size, float x, float y, float width, float height)
{
return string.Format ("<quad material={0} size={1} x={2} y={3} width={4} height={5} />", index, size, x, y, width, height);
}
public static string Quad (int size, float x, float y, float width, float height)
{
return string.Format ("<quad size={0} x={1} y={2} width={3} height={4} />", size, x, y, width, height);
}
// ===============
// Styles
//================
public static string Label (this string text)
{
return text.Middle ();
}
public static string MiniLabel (this string text)
{
return text.Small ();
}
public static string LargeLabel (this string text)
{
return text.Large ();
}
public static string BoldLabel (this string text)
{
return text.Middle ().Bold ();
}
public static string MiniBoldLabel (this string text)
{
return text.Small ().Bold ();
}
public static string LargeBoldLabel (this string text)
{
return text.Large ().Bold ();
}
public static string WhiteLabel (this string text)
{
return text. Middle ().White ();
}
public static string WhiteLargeLabel (this string text)
{
return text.Large ().White ();
}
public static string WhiteMiniLabel (this string text)
{
return text.Small ().White ();
}
public static string WhiteBoldLabel (this string text)
{
return text.Middle ().White ();
}
public static string WhiteMiniBoldLabel (this string text)
{
return text.Small ().White ();
}
public static string WhiteLargeBoldLabel (this string text)
{
return text.Large ().White ();
}
public static string BlackLabel (this string text)
{
return text. Middle ().Black ();
}
public static string BlackLargeLabel (this string text)
{
return text.Large ().Black ();
}
public static string BlackMiniLabel (this string text)
{
return text.Small ().Black ();
}
public static string BlackBoldLabel (this string text)
{
return text.Middle ().Black ();
}
public static string BlackMiniBoldLabel (this string text)
{
return text.Small ().Black ();
}
public static string BlackLargeBoldLabel (this string text)
{
return text.Large ().Black ();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment