#if UIWIDGETS_TMPRO_SUPPORT
namespace UIWidgets
{
using UnityEngine;
using UnityEngine.UI;
///
/// TextTMPro.
///
public class TextTMPro : ITextProxy
{
///
/// Is enum value has specified flag?
///
/// Enum value.
/// Flag.
/// true if enum has flag; otherwise false.
public static bool IsSet(TMPro.FontStyles value, TMPro.FontStyles flag)
{
return (value & flag) == flag;
}
///
/// Text component.
///
protected TMPro.TextMeshProUGUI Component;
///
/// GameObject.
///
public GameObject GameObject
{
get
{
return Component.gameObject;
}
}
///
/// Graphic component.
///
public Graphic Graphic
{
get
{
return Component;
}
}
///
/// Color.
///
public Color color
{
get
{
return Component.color;
}
set
{
Component.color = value;
}
}
///
/// Font size.
///
public float fontSize
{
get
{
return Component.fontSize;
}
set
{
Component.fontSize = value;
}
}
///
/// Font style.
///
public FontStyle fontStyle
{
get
{
if (Bold && Italic)
{
return FontStyle.BoldAndItalic;
}
if (Bold)
{
return FontStyle.Bold;
}
if (Italic)
{
return FontStyle.Italic;
}
return FontStyle.Normal;
}
set
{
Bold = (value == FontStyle.Bold) || (value == FontStyle.BoldAndItalic);
Italic = (value == FontStyle.Italic) || (value == FontStyle.BoldAndItalic);
}
}
///
/// Bold.
///
public bool Bold
{
get
{
return IsSet(Component.fontStyle, TMPro.FontStyles.Bold);
}
set
{
if (Bold == value)
{
return;
}
if (value)
{
Component.fontStyle |= TMPro.FontStyles.Bold;
}
else
{
Component.fontStyle &= ~TMPro.FontStyles.Bold;
}
}
}
///
/// Italic.
///
public bool Italic
{
get
{
return IsSet(Component.fontStyle, TMPro.FontStyles.Italic);
}
set
{
if (Italic == value)
{
return;
}
if (value)
{
Component.fontStyle |= TMPro.FontStyles.Italic;
}
else
{
Component.fontStyle &= ~TMPro.FontStyles.Italic;
}
}
}
///
/// Text.
///
public string text
{
get
{
return Component.text;
}
set
{
Component.text = value;
}
}
///
/// Initializes a new instance of the class.
///
/// Component.
public TextTMPro(TMPro.TextMeshProUGUI component)
{
Component = component;
}
}
}
#endif