- Home /
Change fonts from within single Text object?
Is there a way for me to change fonts while in the same Text object? This way I can keep sprite glyphs a secondary font and switch to them when I need them.
Answer by wesleywh · Dec 16, 2014 at 07:18 PM
You can change just the text by using " Some Text ".
Here is an example using the GUI label:
GUI.Label(Rect(10,10, 100, 50),"<size=20>Text</size>");
EDIT: Well good thing I added the example because the whole "" thing doesn't show up lol.
To be more specific I'm working with the UnityEngine.UI.Text object. Is there any way to do this without the GUI.Label object? Just trying to keep the rendering transformations of my objects uniform.
I haven't used that before. The GUI.Label is just an example all you need is this:
"<size=WhateverSize> Your Text Here </size>"
Is that actually changing the font? Looks like it's just changing the size...
Oh Wow I feel dumb... sorry about miss reading. You are very correct in thinking that it will only change the size of those characters. So I tried to do a little more research on this subject and I came up with these links for you:
Answer by BMayne · Dec 16, 2014 at 10:53 PM
Hey there,
Unfortunately there does not seem to be a nativ way to do this with UnityEngine.UI Most of the code driving the creation of the text is written in C++ which you have no access too and it does not take in two font materials. There is a very round about and hack way to get a max of two fonts but it requires a lot of work.