So... all the dynamic font solutions (this is what, 3rd one in 2 days now? :)) are limited by the same clause -- that is the font must be in a separate texture and can't be using the atlas texture, right?yep, it uses the dynamic font texture, the amount of texture is decided by how many fonts we use
So... all the dynamic font solutions (this is what, 3rd one in 2 days now? :)) are limited by the same clause -- that is the font must be in a separate texture and can't be using the atlas texture, right?
So... all the dynamic font solutions (this is what, 3rd one in 2 days now? :)) are limited by the same clause -- that is the font must be in a separate texture and can't be using the atlas texture, right?Unity create the font texture dynamically according to the list of chars u used with this font, so is that possible to add a texture dynamically into an atlas(as i remember, it's quite difficult), and then change it every time when u use a new char(like the chat window, who knows every players?)?
Regarding memory management, the beauty of it is that the texture tends to use only the characters that are in use at a given moment. That is, suppose you have a font texture that holds a lot of 72px characters because you are showing a splashscreen GUI, for instance, next when you move on to another screen, like for instance an inventory menu, if you start using smaller characters of the same font, say 16px for titles and 12px for subtitles, whenever the texture is full it will be rebuilt, but without the 72px characters since they are nolonger in use on screen.
I've got my own integration mostly working and I am happy to share it too for free. At first I considered putting a price on it, but I'm happy to share it freely as every one seems excited about this. As long as I don't have to answer zillions of questions about it, I'm happy to share.
Eventually, ArenMook, I really think you should get down to integrating this in NGUI. It's not a lot of code, and what worries me about my own solution or any solution I could pick up on this forum is maintainance --> since I basically modified some of your source code, everytime you submit an update in assetstore, it's still going to be a bit clumsy to apply my patch on top of it.
@UnisipNice job, man. I've read your code and test it. But the problem what I have mentioned seems not solved. Here is ur program's result -- all the text is above the top corner.
I've ever try not change the size setting in the font asset, but failed. May I know how u calculate the v0.y to make all text inside the box? e.g. the font asset's name is YouYuan, with size 16, the characterInfo.vert.y of 国 with size 16 is correct, it's -0.125f, so just set v0.y=(y - 0.125f)*scale.y is OK, but the characterInfo.vert.y of 国 with size 64 is 35.88f, and then what's the correct v0.y?
yeah there's this weird thing with vertical offsets. Frankly I haven't bothered too much about it since I was testing with smaller fonts like 12 to 18px, but I agree that this is problematic.I've searched the Unity's forum, no answer to it, After many times experiment, I found that when set the font asset's size to ONE, a magic solution come out.
I'll try to have another look at this issue too. It seems we don't fully understand the values that the CharacterInfo class gives us for positioning fonts. In fact it might make sens to try to figure that out even outside of the NGUI context
Ok I *think* I might have something that makes more sense.it still works not perfectily, I use YouYuan font, size 16 and test UILabel with char size 16, 64. Here is the result.
No more magic number, it relies on the font import size (which unfortunately can't be accessed from code, it seems, so I set the value to a constant 16, since when you import a font, its size is set to 16.
zh4ox, can you test this and tell me what you think?
@wsicarlos: what I found in my tests was the following:
- when you add new chars to the font texture, if the texture has to be rebuilt (to change its size), it will only be rebuilt with those new chars. All older chars are removed, and the texturerebuilt callbacks are invoked. On callback, you can have other gameobjects displaying text (UILabels, but also text meshes if needed) request their characters to be added to the font texture again. Any object that doesn't request its characters again takes the risk of not finding them in the texture anymore. Anyway, see my code for it, a diff with the original NGUI version will point you to the changes I made.
Unisip, u are awesome, I stiil have much work to do
Shader Name need space.
Unlit/Transparent Colored (DynamicFont)(SoftClip) --> Unlit/Transparent Colored (DynamicFont) (SoftClip)
Unlit/Transparent Colored (DynamicFont)(HardClip) --> Unlit/Transparent Colored (DynamicFont) (HardClip)
Unlit/Transparent Colored (DynamicFont)(AlphaClip) --> Unlit/Transparent Colored (DynamicFont) (AlphaClip)
thanks for ink‘s help, I know the solution of my problem mentioned before.
New problem!!!!The Character became thin.It indeedly became thin.(It seems the all the shaders for dynamic font will make the printed character thin)
Please help me!Any help will be appreciated^_^
You're awesome^_^
Recently I was also working on Dynamic font support for NGUI.I used a similar mothed just as you offered. A problem puzzled me.You know,I just used the Panel Clipping(Soft Clip) to make a Scrool List.But it did not work normally,I mean the clipping bounder could not clip the Lables.I have tried some shaders,including the Shaders you offered (specified shaders for dynamic font such as "Unlit - Transparent Colored (DynamicFont)"....).
Then I used the "Unlit - Transparent Colored (Packed)" shader offered in Ngui's new edition and It really worked.Unfortunately,The color of Lables chaged and became another color that was similar to the original color.
Have you ever encountered such problem.Please give me some help,3Q O(∩_∩)O~
thanks for ink‘s help, I know the solution of my problem mentioned before.
New problem!!!!The Character became thin.It indeedly became thin.(It seems the all the shaders for dynamic font will make the printed character thin)
Please help me!Any help will be appreciated^_^
Yeap, after updated to 2.3.1, there are some compile error when I import DynamicFont.unitypackageIs the Package Released?
I would have been nice if it was built in to NGUI by default..hint hint nudge nudge. 8)Yeahh, this should be into NGUI!
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?
You're awesome^_^
Recently I was also working on Dynamic font support for NGUI.I used a similar mothed just as you offered. A problem puzzled me.You know,I just used the Panel Clipping(Soft Clip) to make a Scrool List.But it did not work normally,I mean the clipping bounder could not clip the Lables.I have tried some shaders,including the Shaders you offered (specified shaders for dynamic font such as "Unlit - Transparent Colored (DynamicFont)"....).
Then I used the "Unlit - Transparent Colored (Packed)" shader offered in Ngui's new edition and It really worked.Unfortunately,The color of Lables chaged and became another color that was similar to the original color.
Have you ever encountered such problem.Please give me some help,3Q O(∩_∩)O~
Hmm, I've seen that too, but it hasn't had any problems; all the characters are shown. Odd.
Do remember that since they use their own material, you have to move the Label forward on the Z position, or it will likely be hidden behind other widgets. I usually keep my labels at -1, while the rest is at 0.
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?
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.
private static void OnFontRebuilt() { foreach (var r in roots) { UILabel[] labels = r.GetComponentsInChildren<UILabel>(true); foreach (UILabel label in labels) { if (label.font != null) // here you can check more to make this correct. { label.MarkAsChanged(); } } // just check //Debug.LogWarning(string.Format("{0} has {1} UILabel.", r.name, ((labels != null && labels.Length > 0) ? (labels.Length) : (0)))); } }
I hope it will be helpful to you :)
Can anyone pack a full dynamic font package for NGUI2.3.4 & Unity4.0.1?+1 ;D
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.I just update to NGUI 2.3.4 with this Dynamic Font files and all the labels 'move up' like 50 pixels.
ArenMook, if I were to clean it up a little and made a pull request, would you consider letting it into the mainline?
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.How about prepared for NGUI 2.3.6?
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).That sounds like a really good features and fixes. This are in the 2.3.6 Pro version?
+1 ;D2.3.6 Version
You would have to do it in the shader then.
You can add that in your own shader if you want it though.That should be the material I'm using for the Dynamic Font? or the the texture or material inside TTF?
No. 2.3.6 is out already. Those will be in a coming version
I have some issues when using fonts on 3D cameras, sometimes when I add more assets they just disappear and if I move 1 of the labels on the Z-axis (ie: -45) appears all the labels again. Which could be the problem?
This appears because dynamic fonts use own material, so you need to adjust Z-axis as it's done with different atlases.And there's no fixes for this?
New version (2.5.0) and no Dynamic Font, that's a shame... anyways a lot of cool things.
It sounds like it is on the list for ArenMook to get implemented into NGUI after GDC. I'm really looking forward to this feature being officially integrated as well.
And there's no fixes for this?
Dynamic font support will be in 2.6.0. I was busy with GDC for the past 2 weeks.
Dynamic font support will be in 2.6.0. I was busy with GDC for the past 2 weeks.
Great news! Thanks! BTW when will it be released?There's any ETA?