Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: DarkMagicCK on April 08, 2013, 02:51:58 AM

Title: Dynamic Font package for NGUI 2.5.1 (for unity 4.x)
Post by: DarkMagicCK on April 08, 2013, 02:51:58 AM
Hello guys, I spent some hours to merge most of the great works done by great people in the top thread, and made a merge package for NGUI 2.5.1.
Here's some merge node:
1. UIFont and UIFontInspector dynamic font support from @Unisip.
2. yOffset logic and inspector support from @zh4ox and @Mudwiz.
3. Support clipping, Clip shaders from great @Nicki. As hard clip is not suggested, use alpha clip instead.

As dynamic fonts are only avaliable in unity 4.x, this package does not support 3.x.
How to use this package to setup dynamic fonts:
1. Import font ttf file and set font size to 1.
2. Create a new gameobject, attach a UIFont script and make this a prefab.
3. Adjust prefab inspector values.
    (http://www.tasharen.com/forum/index.php?action=dlattach;topic=3749.0;attach=1735)
    Font Type: Choose DYNAMIC.
    Font: Drag your ttf file into this slot.
    Material: You need to create a new material with "Unlit/Dynamic Text Shader" for each different font, same font with different size can use same material.
    Size: the font size you want.
    TTF Size: size of the ttf import setting, as this situation, set it to 1.
    Const Offset: default the text's y offset is not correct(still no solution yet), and this value can be different for different fonts. You can adjust this value to fit the texts in box, other sizes of the same font will mostly be correct.
4. Create UILabel using this prefab as UIFont and that's it.
Title: Re: Dynamic Font for NGUI 2.5.1
Post by: tkok on April 08, 2013, 03:22:18 AM
I tried to import NGUI_2.5.1_DynamicFont.unitypackage -package and I only got an error:
Quote
"Fatal error!
type == kMetaAssetType && pathName.find ("library/metadata") != 0"

And then unity crashes.

System: Mac os x 10.7.5
Unity: 3.5.7f6

I fastly tried it with my windows pc and it did give me same error.
Title: Re: Dynamic Font for NGUI 2.5.1
Post by: DarkMagicCK on April 08, 2013, 03:26:08 AM
I tried to import NGUI_2.5.1_DynamicFont.unitypackage -package and I only got an error:
"Fatal error!
type == kMetaAssetType && pathName.find ("library/metadata") != 0"
And then unity crashes.

System: Mac os x 10.7.5
Unity: 3.5.7f6

I fastly tried it with my windows pc and it did give me same error.

NGUI 2.5.1 only support unity 4.0+, so this package is for unity 4.0+
Title: Re: Dynamic Font package for NGUI 2.5.1 (for unity 4.x)
Post by: Nicki on April 08, 2013, 05:15:48 AM
Cool package.
A note though - NGUI 2.5.1 supports Unity 3.5.5 and up, but dynamic fonts only work in Unity4 (at least for mobile).
Title: Re: Dynamic Font package for NGUI 2.5.1 (for unity 4.x)
Post by: pretender on April 08, 2013, 05:16:09 AM
In release notes it does not say that ngui is unity 4+ only but 3.5+ (but dynamic font is unity4+ only feature)
Title: Re: Dynamic Font package for NGUI 2.5.1 (for unity 4.x)
Post by: DarkMagicCK on April 08, 2013, 06:46:59 AM
Cool package.
A note though - NGUI 2.5.1 supports Unity 3.5.5 and up, but dynamic fonts only work in Unity4 (at least for mobile).
lol thanks, I've changed the note.
Title: Re: Dynamic Font package for NGUI 2.5.1 (for unity 4.x)
Post by: jeldrez on April 08, 2013, 09:36:13 AM
Thanks DarkMagic!
a solution until v.2.6.0 is coming.
Title: Re: Dynamic Font package for NGUI 2.5.1 (for unity 4.x)
Post by: agrignon on April 08, 2013, 04:31:45 PM
Thx! Just gave this a shot, and seem to hit a problem with > 1 font. The most recently edited font works fine, while the other dynamic fonts get corrupted. In my case I'm using 3 typefaces, and whatever I edit most recently (ie, just changing the style from Normal to Bold in the panel) will look correct while the other fonts show up as gibberish.

Title: Re: Dynamic Font package for NGUI 2.5.1 (for unity 4.x)
Post by: DarkMagicCK on April 08, 2013, 10:18:33 PM
Thx! Just gave this a shot, and seem to hit a problem with > 1 font. The most recently edited font works fine, while the other dynamic fonts get corrupted. In my case I'm using 3 typefaces, and whatever I edit most recently (ie, just changing the style from Normal to Bold in the panel) will look correct while the other fonts show up as gibberish.
You need to setup new material for new fonts, I just made one default Material in NGUI/Resources/Material.
Create material with shader Unlit/Dynamic Text Shader anywhere, and put this into new font's prefab.
Title: Re: Dynamic Font package for NGUI 2.5.1 (for unity 4.x)
Post by: jeldrez on April 08, 2013, 10:27:51 PM
yeps, it happens to me before. You need to check the font material.
Title: Re: Dynamic Font package for NGUI 2.5.1 (for unity 4.x)
Post by: huixiong on April 09, 2013, 02:57:56 AM
some time, i meant this solution:in phone, some of the world cannot be printed.
Maybe When UIFont callback OnFontRebuilt() function,some labels were not be repaint in cellphone android environment.
Can you help me ?
ps:
   font.dynamicFont.textureRebuildCallback += OnFontRebuilt;
Title: Re: Dynamic Font package for NGUI 2.5.1 (for unity 4.x)
Post by: jarjin on April 09, 2013, 04:12:15 AM
Thanks DarkMagic!
a solution until v.2.6.0 is coming.
+1
Title: Re: Dynamic Font package for NGUI 2.5.1 (for unity 4.x)
Post by: agrignon on April 09, 2013, 11:17:24 AM
You need to setup new material for new fonts, I just made one default Material in NGUI/Resources/Material.
Create material with shader Unlit/Dynamic Text Shader anywhere, and put this into new font's prefab.

Perfect - working now, thanks!
Title: Re: Dynamic Font package for NGUI 2.5.1 (for unity 4.x)
Post by: Groszq on April 09, 2013, 11:56:42 AM
Do I have to create new materials for new fonts, because I met with opposite solutions?
Title: Re: Dynamic Font package for NGUI 2.5.1 (for unity 4.x)
Post by: agrignon on April 09, 2013, 05:34:32 PM
You need to setup new material for new fonts, I just made one default Material in NGUI/Resources/Material.
Create material with shader Unlit/Dynamic Text Shader anywhere, and put this into new font's prefab.

One more thing... in looking at the output from my previous screenshot, you'll see the baseline of the font seems off making look a bit like a ransom note. When I used this previously with BMFont (with only using the 'recommended' settings for NGUI) it looked correct. Do you know if there something else I can tweak to make this more even?
Title: Re: Dynamic Font package for NGUI 2.5.1 (for unity 4.x)
Post by: DarkMagicCK on April 09, 2013, 10:51:16 PM
some time, i meant this solution:in phone, some of the world cannot be printed.
Maybe When UIFont callback OnFontRebuilt() function,some labels were not be repaint in cellphone android environment.
Can you help me ?
ps:
   font.dynamicFont.textureRebuildCallback += OnFontRebuilt;
Sorry I do not own an android device, this package has not been tested on android.
Someone else can help?
Title: Re: Dynamic Font package for NGUI 2.5.1 (for unity 4.x)
Post by: DarkMagicCK on April 09, 2013, 11:14:51 PM
One more thing... in looking at the output from my previous screenshot, you'll see the baseline of the font seems off making look a bit like a ransom note. When I used this previously with BMFont (with only using the 'recommended' settings for NGUI) it looked correct. Do you know if there something else I can tweak to make this more even?
Oh I see that, like one pixel clip.
The char uv info is from UnityEngine.Font, there's not much we can done for this.
Font's texture's filter mode is unchangable either.
Only one thing - the font's importing settings has a Rendering Mode option. I tried OS Default, but the result is like shit.
Title: Re: Dynamic Font package for NGUI 2.5.1 (for unity 4.x)
Post by: huixiong on April 11, 2013, 07:26:47 AM
Sorry I do not own an android device, this package has not been tested on android.
Someone else can help?
I found that:in android env,when rebuild dynamicFontMaterial,some of the labels's letters were not be printed to the material.
can these letters be printed first,then cleaned last?
And
    when i disable a panel, then enable it, the letters are not be printed,is it?
my sys is android 4.0.4. sony lt26i
Title: Re: Dynamic Font package for NGUI 2.5.1 (for unity 4.x)
Post by: Sayid on April 11, 2013, 08:51:30 PM
I got a problem here.Once I set the dynamic font size in prefab, I can not change it anymore(I mean , I can change it in inspector, but it will set back when I am running my project). Can you give me some ideas ? Thanks.
Title: Re: Dynamic Font package for NGUI 2.5.1 (for unity 4.x)
Post by: Sayid on April 11, 2013, 08:58:11 PM
Alright. I got a solution.Remove UIFont script,and re-Add it.Now you can set you dynamic font with a new size, Then it will be saved.  :o :o
Title: Re: Dynamic Font package for NGUI 2.5.1 (for unity 4.x)
Post by: Antares88 on April 13, 2013, 02:44:29 AM
Hi!
First of all I'd like to thank you for this job. Using bitmap fonts was a pain in the ass :D

I had a little issue though: I made a label, the text is showing correctly but it's initially rendered in the back of everything, like if the label was under everything else.
 
I managed to bring it in front touching the Z transform and inserting a negative value. Why the depth is not working ?
When i try to modify it i get this warning: "the widgets underneath this panel are using more than one atlas. You may need to adjust transform position's Z value instead.
Title: Re: Dynamic Font package for NGUI 2.5.1 (for unity 4.x)
Post by: Nicki on April 13, 2013, 09:08:12 AM
http://www.tasharen.com/forum/index.php?topic=1858.0
Title: Re: Dynamic Font package for NGUI 2.5.1 (for unity 4.x)
Post by: ameno on April 15, 2013, 09:00:41 AM
Hi there, I got a annoying problem when using the dynamic font.
1. I have one main menu button panel with text on each button (start, options, credits).
2. I have another options panel, with a UITexture background. When I bring this panel up, the font of my button appear in front of my UITexture background of my new panel. I have tried to move the Z axis, value of -1, -5, -100, -200 to bring further forward the panel to the camera, but that doesn't work. I have always my main menu button font text on the front of my UITexture options background.
3. If I changed my dynamic font to a BMFont, the font appear correctly in the back of my UITexture.

Any hints to fix that ? I want to use the dynamic font, not the BMFont.
Thank you.

p.s. The problem is from the UITexture script, if I use UISprite instead, this fix the problem.
Title: I have a solution
Post by: hmnyari on April 15, 2013, 10:18:50 PM
Const Offset: default the text's y offset is not correct(still no solution yet), and this value can be different for different fonts. You can adjust this value to fit the texts in box, other sizes of the same font will mostly be correct.

this const offset value not saved
when open unity, value becomes 0

but I found solution 
go to font importer and change font size what you want.(not 1)
I think const offset is Unnecessary.   
Title: Re: Dynamic Font package for NGUI 2.5.1 (for unity 4.x)
Post by: garrynewman on April 18, 2013, 09:40:15 AM
This solved all my problems! Thanks!

I was having problems with the kerning being all over the place on fonts I was generating. This gets rid of that problem.. and allows for unicode without any issues too!

http://i.imm.io/13eLX.png
Title: Re: Dynamic Font package for NGUI 2.5.1 (for unity 4.x)
Post by: badawe on April 18, 2013, 03:06:36 PM
GREAT JOB =D
Title: Re: Dynamic Font package for NGUI 2.5.1 (for unity 4.x)
Post by: ArenMook on April 19, 2013, 06:28:50 PM
2.6.0 is out to Pro users and has dynamic font support.
Title: Re: Dynamic Font package for NGUI 2.5.1 (for unity 4.x)
Post by: jarjin on April 19, 2013, 08:35:59 PM
2.6.0 is out to Pro users and has dynamic font support.
When can we download?
Title: Re: Dynamic Font package for NGUI 2.5.1 (for unity 4.x)
Post by: ArenMook on April 19, 2013, 11:02:31 PM
When Pro users say that it's all peachy and there aren't any issues. :)
Title: Re: Dynamic Font package for NGUI 2.5.1 (for unity 4.x)
Post by: Antares88 on April 23, 2013, 03:30:43 AM
do we have to remove the files of this library before updating to ngui 2.6 ?

if yes, what files ?
Title: Re: Dynamic Font package for NGUI 2.5.1 (for unity 4.x)
Post by: ArenMook on April 23, 2013, 08:16:41 AM
Just follow the standard NGUI update process -- delete everything.
Title: Re: Dynamic Font package for NGUI 2.5.1 (for unity 4.x)
Post by: Antares88 on May 01, 2013, 04:06:14 AM
Hi, I'm using NGUI 2.5.1 with this package for dynamic text.
Sometimes I get the whole text messing up like in this picture. Totally randomly, I'm not able to replicate it. When it happens, I just restart the game and soon it goes away.

http://db.tt/7PMaJCDe

What may it be ?
Title: Re: Dynamic Font package for NGUI 2.5.1 (for unity 4.x)
Post by: hitmax87 on June 28, 2013, 03:50:24 AM
I cant try it in Free version  :(