Author Topic: Fontsize no longer sets correctly  (Read 6839 times)

markbsfs

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 19
    • View Profile
Fontsize no longer sets correctly
« on: February 27, 2014, 09:27:39 PM »
I recently upgraded from 3.4.8 to 3.5.1, and now...

  UILable label;
  lable.fontSize = N;   // where N can be any integer

no longer works in all cases.  I am using NGUI fonts (Arimo20 (UIFont).

In the simplest case, I have a UITexture + UILabel, and when I run the code, no matter the value I put in fontSize, it uses (I think) 20.  This occurs whether I change the value in code or in the inspector in the prefab.

In another case, I have a UISprite + Box Collider + UIImageButton + UILabel, and this also ignores new values in fontSize -- the text itself doesn't get bigger on screen -- but it does compute the position of the label relative to the button correctly: the larger I make the font, the more it moves the label up and to the left.  This sort of thing may be happening in the previous example, but i cannot easily tell by looking.

In a third case, also a UISprite + Box collider + UIImageButton + UIlabel, it works fine.  I can't see any difference in the setup between these last two cases.

These all worked correctly in 3.4.8.  Any ideas?

Thanks




ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Fontsize no longer sets correctly
« Reply #1 on: February 28, 2014, 07:41:36 PM »
Labels by default get created with "shrink content" overflow style. Did you actually change that?

markbsfs

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 19
    • View Profile
Re: Fontsize no longer sets correctly
« Reply #2 on: February 28, 2014, 09:34:14 PM »
No, I did not change it... I just tried each of the four settings, but none changes the result.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Fontsize no longer sets correctly
« Reply #3 on: March 01, 2014, 05:57:43 PM »
When the overflow is set to "shrink content" the dimensions of the text will not change if you switch to a larger size font, because that font likely won't fit. If you set the overflow to "resize freely", then the label's dimensions will be resized based on the text's dimensions.

markbsfs

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 19
    • View Profile
Re: Fontsize no longer sets correctly
« Reply #4 on: March 01, 2014, 10:08:53 PM »
But as I mentioned before, changing to any of the other settings makes no difference.  I just tried it again: resize freely produces the same result as before: the text is moved up and to the left on the button, as if the font were larger, but it displays in the size ~20 font.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Fontsize no longer sets correctly
« Reply #5 on: March 02, 2014, 06:35:26 PM »
Well, I just tried the following:

1. New scene.
2. ALT+SHIFT+L to add a label, chose Arimo20 as the font, size 20, Resize Freely overflow.
3. Added this script to it:
  1. using UnityEngine;
  2.  
  3. public class Abcd : MonoBehaviour
  4. {
  5.         void Start ()
  6.         {
  7.                 GetComponent<UILabel>().fontSize = 40;
  8.         }
  9. }
4. Hit Play. Text becomes double the size.

markbsfs

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 19
    • View Profile
Re: Fontsize no longer sets correctly
« Reply #6 on: March 02, 2014, 08:05:02 PM »
Yeah, the problem is that it doesn't always work, like it used to in 3.4.8.  I have cases where it works and cases where it doesn't, and I was wondering if anything changed from 3.4.8 to 3.5.1 that might have caused this behavior.  As it is now, I don't even have a work around.  My best guess is to try rebuilding my prefabs and see if that makes a difference, but that seems like a long shot.

As yet, I have been able to isolate a case outside my codebase.

markbsfs

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 19
    • View Profile
Re: Fontsize no longer sets correctly
« Reply #7 on: March 03, 2014, 12:24:47 AM »
Sorry, I have been UNABLE to isolate a case outside my codebase.

markbsfs

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 19
    • View Profile
Re: Fontsize no longer sets correctly
« Reply #8 on: March 04, 2014, 12:34:02 AM »
At this point, I don't think I have any choice but to downgrade back to 3.4.8, when font sizes worked in every case.  Has anyone else seen a problem like this?  Any ideas?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Fontsize no longer sets correctly
« Reply #9 on: March 04, 2014, 12:52:44 AM »
Well, you said it yourself, you can't seem to reproduce it outside of your one project -- which suggests that it's something with that particular project. Perhaps the script execution order is different. Did you follow the upgrade instructions from the readme file?

markbsfs

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 19
    • View Profile
Re: Fontsize no longer sets correctly
« Reply #10 on: March 04, 2014, 01:18:36 AM »
I have no problem believing that it's something I'm doing, it's just odd that it worked before and doesn't work now.  No doubt the case of this is the same as those other cause: two widgets on one object.