Author Topic: Texture and Label issues after upgrading NGUI  (Read 3037 times)

sliterod

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 5
    • View Profile
Texture and Label issues after upgrading NGUI
« on: July 22, 2014, 02:46:24 PM »
Hello.

A few days back I posted about black textures in Android.

I'm facing a problem after upgrading from NGUI ver. is 2.6.3 to 3.6.8.
The problem is that all my labels and textures are oversized (the ones that are not inside an Atlas).
In both cases, the size in the widget attributes after the update is 100x100 and the local size is unaffected by the update.

I don't know what to do. I appreciate any suggestion. The UI of the game is huge, and having to rebuild it all over again is going to take much more time.

Thanks in advance.
« Last Edit: July 22, 2014, 09:32:04 PM by sliterod »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Texture and Label issues after upgrading NGUI
« Reply #1 on: July 22, 2014, 09:39:58 PM »
When going from NGUI 2 to NGUI 3, all widgets need to get updated to the new system. In order for this to happen all widgets need to be brought into the scene and enabled, or the upgrade code won't run. After doing so you should apply changes to all your prefabs and save all your scenes.

NGUI 2 used transform scale for widget size. NGUI 3 uses separate width and height values, and scale is no longer used.

sliterod

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Texture and Label issues after upgrading NGUI
« Reply #2 on: July 23, 2014, 01:57:09 PM »
I did as you told me, from the beginning step by step.
The sprites are working fine after using 'upgrade widgets' option in editor but, the textures are still oversized and the labels some are oversized while others are minimized.

I am doing something wrong? or I need to check something else to prevent this from happening?

Thanks in advance
« Last Edit: July 23, 2014, 03:07:46 PM by sliterod »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Texture and Label issues after upgrading NGUI
« Reply #3 on: July 23, 2014, 08:14:54 PM »
Using "Upgrade widgets" from the menu replaced legacy components such as UISlicedSprite with UISprite set to the appropriate parameters. The scale to width/height conversion happens right away, as soon as the widget is enabled -- which is why I mentioned having to bring everything into the scene, enabling them, then applying the changes to the prefabs. If for some reason that doesn't work, and you end up with large widgets due to scale changes, just select the UIRoot and hit ALT+SHIFT+P.

sliterod

  • Newbie
  • *
  • Thank You
  • -Given: 3
  • -Receive: 0
  • Posts: 5
    • View Profile
Re: Texture and Label issues after upgrading NGUI
« Reply #4 on: July 27, 2014, 09:12:43 PM »
I tried the solution you gave me and everything remained the same.

The problem seemed my hierarchy. The sprites, textures and labels that were to deep in the hierarchy were not affected by the upgrade.

To solve the oversize, I made an script that moved them to an upper level on the hierarchy, turned them off and on and returned them to their original parent. It worked with both textures and sprites.

With labels, however is different. After reapplying the update (and before running my script), I noticed that the font size of every updated label was 16, some of them huge and others small. Those labels lost their aspect completely. Only a few cases were without problem.

It has something to do with the font atlas? Or is another issue?

Thanks in advance.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Texture and Label issues after upgrading NGUI
« Reply #5 on: July 27, 2014, 11:23:44 PM »
The labels didn't have a font size before. This setting used to be on the UIFont. You can make NGUI auto-upgrade use the default font size by changing UILabel's UpgradeFrom265() function like this:
  1.                 if (mFont != null)
  2.                 {
  3.                         int min = mFont.defaultSize;
  4.                         if (height < min) height = min;
  5.                         fontSize = min; // <-- add this
  6.                 }