Author Topic: Dynamic font support for NGUI  (Read 89025 times)

jeldrez

  • Sr. Member
  • ****
  • Thank You
  • -Given: 8
  • -Receive: 4
  • Posts: 352
    • View Profile
Re: Dynamic font support for NGUI
« Reply #105 on: March 04, 2013, 03:17:53 PM »
You also have to set the font size on the ttf file.
How is that Nicki? There is a difference between changing the font size on the Dynamic Font (prefab) against the Font itself?
I have my prefab on 100 size and I use the same prefab for smaller text, I just made it smaller. Should I create a new prefab with smaller size for that?

Thanks!

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Dynamic font support for NGUI
« Reply #106 on: March 04, 2013, 05:13:43 PM »
Yeah you should. Unity generates the bitmap texture from the size set directly on the font, while NGUI sets up the localscale based on the size set in the UIFont.

jeldrez

  • Sr. Member
  • ****
  • Thank You
  • -Given: 8
  • -Receive: 4
  • Posts: 352
    • View Profile
Re: Dynamic font support for NGUI
« Reply #107 on: March 04, 2013, 05:43:49 PM »
Ok, thanks a lot!
Probably that's going to solve some issues I have.

 ;D

deathguide

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Dynamic font support for NGUI
« Reply #108 on: March 04, 2013, 10:41:16 PM »
hello,
     
   when font texture rebuild, we have to update all labels.  Is there any solve else?

but how can I update labels disabled,  call MarkAsChanged() when OnEnable?

thanks!

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Dynamic font support for NGUI
« Reply #109 on: March 05, 2013, 04:06:49 AM »
If you update any label, it should update them all.

fredxxx123

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Dynamic font support for NGUI
« Reply #110 on: March 05, 2013, 05:32:29 AM »
hello,
     
   when font texture rebuild, we have to update all labels.  Is there any solve else?

but how can I update labels disabled,  call MarkAsChanged() when OnEnable?

thanks!

Hi, I had the same problem before.
It's my way to solve that.

  1. private static void OnFontRebuilt()
  2. {
  3.         UIRoot[] roots = GameObject.FindObjectsOfType(typeof(UIRoot)) as UIRoot[];
  4.  
  5.         foreach (var r in roots)
  6.         {
  7.             UILabel[] labels = r.GetComponentsInChildren<UILabel>(true);
  8.             foreach (UILabel label in labels)
  9.             {
  10.                 if (label.font != null)  // here you can check more to make this correct.
  11.                 { label.MarkAsChanged(); }
  12.             }
  13.             // just check
  14.             //Debug.LogWarning(string.Format("{0} has {1} UILabel.", r.name, ((labels != null && labels.Length > 0) ? (labels.Length) : (0))));
  15.         }
  16. }
  17.  

I hope it will be helpful to you  :)

deathguide

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Dynamic font support for NGUI
« Reply #111 on: March 05, 2013, 06:09:46 AM »
Hi, I had the same problem before.
It's my way to solve that.

  1. private static void OnFontRebuilt()
  2. {
  3.         UIRoot[] roots = GameObject.FindObjectsOfType(typeof(UIRoot)) as UIRoot[];
  4.  
  5.         foreach (var r in roots)
  6.         {
  7.             UILabel[] labels = r.GetComponentsInChildren<UILabel>(true);
  8.             foreach (UILabel label in labels)
  9.             {
  10.                 if (label.font != null)  // here you can check more to make this correct.
  11.                 { label.MarkAsChanged(); }
  12.             }
  13.             // just check
  14.             //Debug.LogWarning(string.Format("{0} has {1} UILabel.", r.name, ((labels != null && labels.Length > 0) ? (labels.Length) : (0))));
  15.         }
  16. }
  17.  

I hope it will be helpful to you  :)


   Thanks for reply!      bellow is my resolution, modify UILabel, I think there should be a better resolution......
  1.         protected override void OnEnable()
  2.         {
  3.                 base.OnEnable();
  4.                 MarkAsChanged();
  5.         }
  6.  


hexart

  • Guest
Re: Dynamic font support for NGUI
« Reply #112 on: March 05, 2013, 07:08:30 PM »
Can anyone pack a full dynamic font package for NGUI2.3.4 & Unity4.0.1?

148423658

  • Guest
Re: Dynamic font support for NGUI
« Reply #113 on: March 05, 2013, 08:37:40 PM »
hwo to do this?

pengyingh

  • Guest
Re: Dynamic font support for NGUI
« Reply #114 on: March 06, 2013, 02:03:04 AM »
It also acts in new version of NGUI after making some changes in UIFont and FontInspector class.Then new a material, set it 's shader to unlit/transparent(packed), link the new material to font prefeb, thus the dynamic font can be clipped by UIPanel, it 's awesome! Hopeing this feature could be joined in new version of NGUI.
« Last Edit: March 06, 2013, 02:10:41 AM by pengyingh »

jeldrez

  • Sr. Member
  • ****
  • Thank You
  • -Given: 8
  • -Receive: 4
  • Posts: 352
    • View Profile
Re: Dynamic font support for NGUI
« Reply #115 on: March 06, 2013, 07:35:31 AM »
Can anyone pack a full dynamic font package for NGUI2.3.4 & Unity4.0.1?
+1 ;D

jeldrez

  • Sr. Member
  • ****
  • Thank You
  • -Given: 8
  • -Receive: 4
  • Posts: 352
    • View Profile
Re: Dynamic font support for NGUI
« Reply #116 on: March 07, 2013, 09:18:49 AM »
So this was made for 2.3.3f and we've since moved to 2.3.3h, but I don't think anything has changed in fonts since then. In any case, these files work properly.

ArenMook, if I were to clean it up a little and made a pull request, would you consider letting it into the mainline?
I just update to NGUI 2.3.4 with this Dynamic Font files and all the labels 'move up' like 50 pixels.

It's just me?

Nicki

  • Global Moderator
  • Hero Member
  • *****
  • Thank You
  • -Given: 33
  • -Receive: 141
  • Posts: 1,768
    • View Profile
Re: Dynamic font support for NGUI
« Reply #117 on: March 07, 2013, 09:43:00 AM »
Hmm, I have 2.3.4 and it works fine for me. I'll make a package for it a little later and put here.

jeldrez

  • Sr. Member
  • ****
  • Thank You
  • -Given: 8
  • -Receive: 4
  • Posts: 352
    • View Profile
Re: Dynamic font support for NGUI
« Reply #118 on: March 07, 2013, 10:32:05 AM »
Ok, thanks Nicki!
Anyway I remember saw this issue also in the early versions too.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,154
  • Toronto, Canada
    • View Profile
Re: Dynamic font support for NGUI
« Reply #119 on: March 09, 2013, 05:12:23 AM »
This package's addition is one of two important modifications that will be hitting the Pro version of NGUI in a short while. I am very hesitant about both, so I will most likely keep them Pro-only for a few weeks until I make sure that there are no adverse side-effects (the other feature is the potential fix for the Z vs depth distinction, in case you're curious).