c# - How to change Font type in Unity? -
how program can change font type to: coalition or arial...
here current code...
using unityengine; using system.collections; public class invslothandler : monobehaviour { private int excess = 1; uilabel lbl; void start() { gameobject label = new gameobject(); lbl = label.addcomponent<uilabel>(); label.transform.name = "#qty"; lbl.fontstyle = fontstyle.normal; lbl.fontsize = 15; lbl.alignment = nguitext.alignment.right; nguitools.addchild (gameobject.transform.gameobject, label.gameobject); } void fixedupdate() { lbl.text = gameobject.transform.childcount - excess + ""; } }
here example of how change font of uilabel uses dynamic font in ngui.
the label shows text in original font 2 seconds, switches other font (the 1 assign otherfont in inspector)
using unityengine; using system.collections; public class changefont : monobehaviour { public uilabel label; public font otherfont; ienumerator start() { label.text = "this bit of text"; //show text yield return new waitforseconds(2f); //wait 2 seconds label.truetypefont = otherfont; //change font } } if label set use bitmap font, you'd assign uifont label.bitmapfont instead.
Comments
Post a Comment