Author Topic: How to set up reference font  (Read 9205 times)

gecko64

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
How to set up reference font
« on: March 11, 2014, 09:42:25 PM »
I've set up Reference Atlases with the LoadAtlas script, but I don't understand how to set up Reference Fonts. I thought I'd create a reference font for each font prefab, and then put LoadAtlas script on the UIRoot just like I've done for the Reference Atlases. But when I do that, I can't assign the Reference Font to the Reference Atlas slot in the inspector -- it rejects it, being the wrong type of object. So...do I put the LoadAtlas script on each Reference Font, or what do I do?

Edit: Oh, and in case it matters: this project is still on NGUI 2. (It's an old project, I'm just doing a higher-rez version, and can't do all the mods necessary to upgrade it to NGUI 3.)

thanks
Dave

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to set up reference font
« Reply #1 on: March 11, 2014, 11:45:40 PM »
NGUI 2 is not supported. It's free now, and has been for a while -- and as such doesn't come with support.

Try this in NGUI 3, it should work as expected.

gecko64

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: How to set up reference font
« Reply #2 on: March 12, 2014, 08:54:08 AM »
So as I said, I am not going to upgrade to NGUI 3 due to the work involved, and all I need to do with this project is up-rez the graphics. But that's just too bad for me, because I didn't happen to tackle it a year ago? Can you give me any hints?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to set up reference font
« Reply #3 on: March 12, 2014, 06:39:29 PM »
I just re-read what you wrote:
Quote
I can't assign the Reference Font to the Reference Atlas slot in the inspector
...? Reference fonts are one thing, reference atlases are another. Both work the same, but they're obviously different things. Create a game object, put UIFont on it, set it to be a Reference font, make it point to another font prefab. Save it as a prefab. There, you have a reference font.

gecko64

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: How to set up reference font
« Reply #4 on: March 13, 2014, 10:09:08 AM »
Thanks for the reply. But that part I understand. My question is: how to use Reference Fonts (with UIFont) with a LoadAtlas (or similar) script -- so the correct font prefab is selected? (I have already set up LoadAtlas to choose the correct Font Atlas, but that doesn't seem to switch the individual font prefabs. I have created Reference Fonts but can't figure out how to use the Load Atlas script (or something comparable) with them.

thanks
Dave

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to set up reference font
« Reply #5 on: March 14, 2014, 12:26:22 PM »
LoadAtlas script?

Reference fonts and atlases are two different entities, and if you have an atlas that has fonts in it you will also need to load your fonts at the same time as loading your atlases, and change your reference fonts to point to the correct font prefabs at the same time as you're changing your reference atlases to point to the correct atlas prefabs.

gecko64

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 15
    • View Profile
Re: How to set up reference font
« Reply #6 on: March 14, 2014, 12:31:29 PM »
I know. That was my question -- how to load the correct set of font prefabs, so they'll match the Font Atlas being loaded via the LoadAtlas script. I can't figure out how to use a Reference Font to do that. 

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to set up reference font
« Reply #7 on: March 14, 2014, 12:42:26 PM »
You have to know which fonts to load.

So if you load your atlas like:
Resources.Load("AtlasHD");

you will also load your font like
Resources.Load("FontHD");