Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - davidoakley

Pages: [1]
1
NGUI 3 Support / Re: UILabel's font size not honouring pixel size in 3.4.9
« on: February 26, 2014, 05:15:17 AM »
Thanks @Fault, I was seeing that too but hadn't got round to describing the problem...

@ArenMook, that fix doesn't seem to do the trick. Here's a before / after screenshot from our game:



All the text is now being scaled by 1 / pixelSize. Seems like the it's just NGUIText.finalLineHeight that needs fixing, as dividing that by 0.5f in NGUIText.Update() fixes the alignment and multi-line problems. But how to affect that without affecting the font scale...?

2
NGUI 3 Support / Re: UILabel's font size not honouring pixel size in 3.4.9
« on: February 24, 2014, 05:58:20 AM »
I've created a test case project, which (predictably?) shows that the system does work as expected, as long as you set the label font size when pixel size is 1.0.

I think that the catch is that the "Default" font size on a label isn't taking the pixel size into account, so in HD (pixel size 0.5), the correct values for the label in my example is:

Font Size: 28 Default: 59

That shows the font pixel perfectly. If you trust the default value and set the label's font size to 59 then it doubles in size.

I'm wondering if it is that prefabs that were created before labels had font sizes get set to their default size on upgrade (which will be at runtime), which is wrong if pixel size <> 1.0? That would make sense. I guess opening each prefab in the editor and applying (when pixel size is 1.0) would do the trick, but I wonder if that upgrade script needs fixing? Sorry I haven't got time right now to get an old NGUI to try that...

David

3
NGUI 3 Support / Re: UILabel's font size not honouring pixel size in 3.4.9
« on: February 21, 2014, 07:24:18 AM »
Hi, thanks for the reply!

My problem happens when switching between NGUI fonts using a reference font.

In your example:

I have Font_SD which is 48 pixels high with pixel size 1.0.
I have Font_HD which is 96 pixels high with pixel size 0.5.
I have a reference font, FontRef, pointing to Font_SD.
I have a label with font size 48 displaying FontRef.

Initially the label shows the 48 pixel-high font at 48 at the correct size.

Now running on a high density device with a UI Root height set to half the real pixel height, I switch FontRef to point to Font_HD.
The label is now showing a 96 pixel high font at size 48, so it shows at 50% of its original size. This causes it to show on-screen at 48 real pixels high rather than the 96 (48 / 0.5) that it should.

Hope that makes sense! If not I can create a small test scene...

4
The short answer is...

Do NGUI -> Create -> Label

In your MonoBehaviour class, add a
  1. public UILabel myLabel;

Back in the editor, select the object that you've got your MonoBehaviour attached to, and drag and drop the Label from the Hierarchy to the My Label field in the Inspector.

Now you can do:
  1. myLabel.text = myFPS.ToString();

Hope that helps!

David

5
NGUI 3 Support / UILabel's font size not honouring pixel size in 3.4.9
« on: February 19, 2014, 06:20:40 AM »
Hi,

I'm using reference fonts/atlases to support pixel densities on mobile devices. Since the introduction of the pixel size property on UILabel I've found that when switching pixel sizes labels jump to double or half their intended font size.

What I'm seeing is that the font size (as seen on the UILabel inspector) is 43 when using the SD (1.0 pixel size) version of a font, but 85 when using HD (0.5 pixel size). That makes sense in terms of real font pixels, but surely the UILabel should work in terms of (font size * atlas pixel size)? Whichever value I fix in the inspector is wrong for the other pixel density screen.

If I force label.fontSize = font.defaultSize then it fixes it OK, but that means having code everywhere to fix things up.

I've checked and the fonts' pixelSizes are correctly picking up the pixelSizes from their parent atlases.

Is there anything I've missed? Normally I try and fix these things myself, but I'm not sure where the right place is to start...

Many thanks,
David

6
NGUI 3 Support / Re: Label issue.
« on: January 27, 2014, 06:46:26 AM »
I think that's related to what I've just seen having upgraded from 3.0.6 to 3.0.9... When using "retina" sized graphics (pixel size 0.5), I'm getting that last-letter wrapping happening too.

My guess is that the width that is being calculated is fractional and is being rounded down, and then when the text is wrapped into that width it pushes the last letter onto the next line.

For me, changing the Mathf.RoundToInt to Mathf.CeilToInt in UILabel.ProcessText seems to have fixed it. Not sure whether that's the correct diagnosis or fix of course!

David

Pages: [1]