本文整理汇总了C#中UnityEngine.Font类的典型用法代码示例。如果您正苦于以下问题:C# Font类的具体用法?C# Font怎么用?C# Font使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Font类属于UnityEngine命名空间,在下文中一共展示了Font类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UguiNovelTextGeneratorAddtionalRuby
internal UguiNovelTextGeneratorAddtionalRuby( List<UguiNovelTextCharacter> characters, int index, Font rubyFont, float rubySizeScale)
{
UguiNovelTextCharacter original = characters[index];
int rubySize = Mathf.CeilToInt(rubySizeScale * original.FontSize);
stringData.Add(original);
for (int i = index + 1; i < characters.Count; ++i)
{
UguiNovelTextCharacter c = characters[i];
if (!c.CustomInfo.IsRuby || c.CustomInfo.IsRubyTop) break;
stringData.Add(c);
}
//カラー情報のみコピー
CharData.CustomCharaInfo rubyInfo = new CharData.CustomCharaInfo();
rubyInfo.IsColor = original.charData.CustomInfo.IsColor;
rubyInfo.color = original.charData.CustomInfo.color;
if (original.charData.CustomInfo.IsEmphasisMark)
{
for (int i = 0; i < stringData.Count; ++i)
{
CharData data = new CharData(original.charData.CustomInfo.rubyStr[0], rubyInfo);
rubyList.Add(new UguiNovelTextCharacter(data, rubyFont, rubySize, original.FontStyle ));
}
}
else
{
foreach (char c in original.charData.CustomInfo.rubyStr)
{
CharData data = new CharData(c, rubyInfo);
rubyList.Add(new UguiNovelTextCharacter(data, rubyFont, rubySize, original.FontStyle ));
}
}
}
示例2: Awake
void Awake()
{
bgTexture = Resources.Load<Texture2D>(Constants.THEME_PATH + Constants.ACTIVE_THEME + "/info_bg");
font = Resources.Load<Font>("Fonts/" + "Chalkboard");
DefaultColor();
}
示例3: Create
public static pb_GUIStyle Create(
Color color,
Color? normalColor = null,
Color? highlightedColor = null,
Color? pressedColor = null,
Color? disabledColor = null,
Texture2D image = null,
Sprite sprite = null,
Font font = null,
Color? fontColor = null)
{
pb_GUIStyle style = ScriptableObject.CreateInstance<pb_GUIStyle>();
style.color = color;
style.image = image;
style.sprite = sprite;
style.font = font;
if(normalColor != null) style.normalColor = (Color) normalColor;
if(highlightedColor != null) style.highlightedColor = (Color) highlightedColor;
if(pressedColor != null) style.pressedColor = (Color) pressedColor;
if(disabledColor != null) style.disabledColor = (Color) disabledColor;
if(fontColor != null) style.fontColor = (Color) fontColor;
return style;
}
示例4: constructor
public static int constructor(IntPtr l)
{
try {
int argc = LuaDLL.lua_gettop(l);
UnityEngine.Font o;
if(argc==1){
o=new UnityEngine.Font();
pushValue(l,true);
pushValue(l,o);
return 2;
}
else if(argc==2){
System.String a1;
checkType(l,2,out a1);
o=new UnityEngine.Font(a1);
pushValue(l,true);
pushValue(l,o);
return 2;
}
return error(l,"New object failed.");
}
catch(Exception e) {
return error(l,e);
}
}
示例5: DefaultFont
/**
* Get default font.
*/
public static Font DefaultFont()
{
if(_defaultFont == null)
_defaultFont = (Font) Resources.GetBuiltinResource(typeof(Font), "Arial.ttf");
return _defaultFont;
}
示例6: SetCharacterInfoToVertex
public static void SetCharacterInfoToVertex(UIVertex[] verts, UguiNovelTextCharacter character, Font font )
{
float minX,maxX,minY,maxY;
Vector2 uvBottomLeft,uvBottomRight,uvTopRight,uvTopLeft;
float offsetY;
#if UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6
//Y座標はフォントアセットのサイズと、文字のサイズを使ってこんな式で計算できる。
//理屈はわからん!
offsetY = font.fontSize + 0.1f*(character.FontSize-font.fontSize);
//positionの設定
minX = character.charInfo.vert.xMin;
maxX = character.charInfo.vert.xMax;
minY = character.charInfo.vert.yMin;
maxY = character.charInfo.vert.yMax;
Rect uv = character.charInfo.uv;
//Flipp処理
if (character.charInfo.flipped)
{
uvBottomLeft = new Vector2(uv.xMax, uv.yMin);
uvBottomRight = new Vector2(uv.xMax, uv.yMax);
uvTopLeft = new Vector2(uv.xMin, uv.yMin);
uvTopRight = new Vector2(uv.xMin, uv.yMax);
}
else
{
uvBottomLeft = new Vector2(uv.xMin, uv.yMax);
uvBottomRight = new Vector2(uv.xMax, uv.yMax);
uvTopLeft = new Vector2(uv.xMin, uv.yMin);
uvTopRight = new Vector2(uv.xMax, uv.yMin);
}
#else
offsetY = 0.1f * (character.FontSize);
//座標の設定
minX = character.charInfo.minX;
maxX = character.charInfo.maxX;
minY = character.charInfo.minY;
maxY = character.charInfo.maxY;
uvBottomLeft = character.charInfo.uvBottomLeft;
uvBottomRight = character.charInfo.uvBottomRight;
uvTopRight = character.charInfo.uvTopRight;
uvTopLeft = character.charInfo.uvTopLeft;
#endif
//座標の設定
verts[0].position.x = verts[3].position.x = minX + character.PositionX;
verts[1].position.x = verts[2].position.x = maxX + character.PositionX;
verts[0].position.y = verts[1].position.y = minY + character.PositionY + offsetY;
verts[2].position.y = verts[3].position.y = maxY + character.PositionY + offsetY;
verts[0].uv0 = uvBottomLeft;
verts[1].uv0 = uvBottomRight;
verts[2].uv0 = uvTopRight;
verts[3].uv0 = uvTopLeft;
}
示例7: OnEnable
void OnEnable()
{
//Load initila variables
SetColors(GetColorDefault(GamestrapHelper.ColorRGBInt(141, 39, 137)));
font = (Font)AssetDatabase.LoadAssetAtPath(GamestrapHelper.gamestrapRoute + "Fonts/Lato/Lato-Regular.ttf", typeof(Font));
SetUpColors();
sceneColors = new List<Color>();
}
示例8: FillText
/// <summary>
/// Fill label mesh.
/// </summary>
/// <param name="mesh">Mesh.</param>
/// <param name="width">Label width.</param>
/// <param name="height">Label height.</param>
/// <param name="text">Label text.</param>
/// <param name="color">Color.</param>
/// <param name="align">Text align.</param>
/// <param name="font">Font.</param>
/// <param name="fontSize">Font size.</param>
/// <param name="lineHgt">Line height multiplier.</param>
/// <param name="effect">Effect.</param>
/// <param name="effectValue">Effect value.</param>
/// <param name="effectColor">Effect color.</param>
public static void FillText(
Mesh mesh, int width, int height, string text, Color color, TextAnchor align, Font font, int fontSize,
float lineHgt, GuiFontEffect effect = GuiFontEffect.None, Vector2? effectValue = null, Color? effectColor = null)
{
if (mesh == null) {
return;
}
mesh.Clear ();
if (font == null || string.IsNullOrEmpty (text)) {
return;
}
_settings.fontSize = (int) (fontSize * GuiSystem.Instance.VirtualToRealScaleFactor);
_settings.resizeTextMaxSize = _settings.fontSize;
var scale = fontSize / (float) _settings.fontSize;
_settings.font = font;
_settings.textAnchor = align;
_settings.generationExtents = new Vector2 (width, height) / scale;
_settings.lineSpacing = lineHgt;
_settings.color = color;
_generator.Invalidate ();
if (!_generator.Populate (text, _settings)) {
return;
}
_generator.GetVertices (_verts);
GuiMeshTools.PrepareBuffer (effect, effectValue, effectColor);
for (int i = 0, iMax = _verts.Count - 4, charID = 0; i < iMax; charID++) {
if (text[charID] == ' ') {
i += 4;
continue;
}
_uiV = _verts[i++];
_c = _uiV.color;
_v0 = _uiV.position * scale;
_uv0 = _uiV.uv0;
_uiV = _verts[i++];
_v1 = _uiV.position * scale;
_uv1 = _uiV.uv0;
_uiV = _verts[i++];
_v2 = _uiV.position * scale;
_uv2 = _uiV.uv0;
_uiV = _verts[i++];
_v3 = _uiV.position * scale;
_uv3 = _uiV.uv0;
GuiMeshTools.FillBuffer (ref _v0, ref _v1, ref _v2, ref _v3, ref _uv0, ref _uv1, ref _uv2, ref _uv3, ref _c);
}
GuiMeshTools.GetBuffers (mesh, false);
mesh.bounds = new Bounds (Vector3.zero, new Vector3 (width, height, 0f));
}
示例9: Clear
public override void Clear()
{
base.Clear();
m_Text = string.Empty;
m_FontSize = 100;
m_Font = null;
m_Color = Color.white;
m_FontTexture = null;
}
示例10: RebuildForFont
private static void RebuildForFont(Font f)
{
List<Text> list;
FontUpdateTracker.m_Tracked.TryGetValue(f, out list);
if (list == null)
return;
for (int index = 0; index < list.Count; ++index)
list[index].FontTextureChanged();
}
示例11: VectorImageData
public VectorImageData(Glyph glyph, Font font)
{
m_Glyph = glyph;
if (!m_Glyph.unicode.StartsWith(@"\u"))
{
m_Glyph.unicode = @"\u" + m_Glyph.unicode;
}
m_Font = font;
}
示例12: CodeView
public CodeView(CodeEditorWindow owner, ITextView textView)
{
m_Owner = owner;
_textView = textView;
_document = _textView.Document;
var textFont = _textView.Appearance.Text.font;
_font = textFont ? textFont : GUI.skin.font;
_navigator = new DefaultTextStructureNavigator();
Caret.Moved += EnsureCursorIsVisible;
_textView.DoubleClicked = DoubleClickedDocument;
}
示例13: TextStyle
/// <summary>
/// Initializes a new instance of the <see cref="Common.App.ResourceTypes.TextStyle"/> class.
/// </summary>
public TextStyle()
{
DebugEx.Verbose("Created TextStyle object");
mFont = null;
mFontStyle = FontStyle.Normal;
mFontSize = 12;
mLineSpacing = 1f;
mAlignment = TextAnchor.UpperLeft;
mColor = new Color(0f, 0f, 0f);
}
示例14: RebuildForFont
private static void RebuildForFont(Font f)
{
List<Text> texts;
m_Tracked.TryGetValue(f, out texts);
if (texts == null)
return;
for (var i = 0; i < texts.Count; i++)
texts[i].FontTextureChanged();
}
示例15: RebuildForFont
private static void RebuildForFont(Font f)
{
List<Text> list;
m_Tracked.TryGetValue(f, out list);
if (list != null)
{
for (int i = 0; i < list.Count; i++)
{
list[i].FontTextureChanged();
}
}
}