Author Topic: pixelsnap on uibutton is total nonsense  (Read 8996 times)

Ugur

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 60
    • View Profile
pixelsnap on uibutton is total nonsense
« on: March 02, 2014, 05:25:12 PM »
I upgraded a project from ngui 3.5. to 3.5.2
The downside is that all fonts look sucky again now, the upside is that text uses a lot less memory, so i guess that was the reason you had to change that..

Anyway, the actual reason of this post is: why is there the property pixelSnap in UIButton.cs now, why is it turned on by default and then making that even worse its not even exposed in the editor script, so one can then only change the value via code.

To me that setting is complete nonsense. What it does is it changes the sprite to the default dimensions. Meaning any dimension change i apply to the sprite gets reset as soon as i add a UIButton script to the sprite containing gameobject. If there is already a UIButton script on the gameobject and i scale the sprite used by the button, it resets the sprites dimensions when hitting play. Who would want that?
Please remove that property again or if you totally want to keep it added, set its default value to false and expose it in the editor script, as it is it completely destroys scaling sprite button options, no use at all.

After looking through it i see why that was added, cause you combined the UIButton code with the UIImageButton code, that's ok, but yeah, then please make that property's default value false and expose it in the editor script, too.
Its just super annoying when one upgrades ngui in a project and each time many things break, like for this upgrade now the look of all my buttons and all text..
« Last Edit: March 02, 2014, 05:44:43 PM by Ugur »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: pixelsnap on uibutton is total nonsense
« Reply #1 on: March 02, 2014, 06:15:31 PM »
Eh... It's under the Sprites section. Did you miss that?

What actually changed with text, and why is the pixel snap causing issues for you? It doesn't come into play unless you set the hover, pressed or disabled states under the Sprites section.

P.S. You can modify the UIButton.SetSprite function to this:
  1.         protected void SetSprite (string sp)
  2.         {
  3.                 if (mSprite != null && !string.IsNullOrEmpty(sp) && mSprite.spriteName != sp)
  4.                 {
  5.                         mSprite.spriteName = sp;
  6.                         if (pixelSnap) mSprite.MakePixelPerfect();
  7.                 }
  8.         }

Ugur

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 60
    • View Profile
Re: pixelsnap on uibutton is total nonsense
« Reply #2 on: March 02, 2014, 08:07:51 PM »
I use a UIButton, not a UIImageButton.
The UIButton does not expose the property pixelSnap for me in the inspector, dunno if it is supposed to.
The pixelsnap property didn't exist in the UIButton.cs before, i guess you added it when merging that script with UIImageButton.cs. In either case that property is now added to UIButton.cs and is set to true in the script by default and that somehow caused all my button sprites to be set reset to 1,1,1 scale and their default pixel dimensions, so got rid of the dimensions i had scaled the sprites scaled.
Only way to get rid of that for me was to change it inside the UIButtonscript to have pixelSnap be set to false. (I also had to set that property to be private else it would ignore me setting it to false in the script. ).


The text issue is a separate issue. Remember, a few dot versions ago you had changed something which would make the text look sharper on mobile and also help with caching the font somehow but somehow also lead to massive memory usage (to the degree where when using a few labels with large text sizes it would crash even on the latest mobile devices due to memory pressure, we had some pm exchanges on that). Now with either 3.5.1 or 3.52 you seem to have changed something in the text handling again which somehow made my labels look blurrier but also lets them use so much less memory that i have no memory crash issues due to using lots of text anymore on mobile, so it looks a bit worse but is not crash prone anymore.
(To make it look less blurry i set the font size a bit larger now and scale the text down a little then).
Overall, yeah, unity's text handling needs a lot of work, its not ok that in 2014 we have to deal with either blurry text (when using small font sizes and scaling it up) or large text using lots of memory (when using large font sizes hence that generating large font atlases)..

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: pixelsnap on uibutton is total nonsense
« Reply #3 on: March 02, 2014, 09:55:30 PM »
The Pixel Snap option is show in inspector under the Sprites sub-section.

Ugur

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 60
    • View Profile
Re: pixelsnap on uibutton is total nonsense
« Reply #4 on: March 02, 2014, 10:04:17 PM »
Dunno why, but for me its not, see:


Besides that, yeah, the default value should just be false in the script in either case for buttons one uses just for coloring and click handling, else it brakes buttons sprites' scaling in many existing features

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: pixelsnap on uibutton is total nonsense
« Reply #5 on: March 02, 2014, 10:06:40 PM »
Curious. Why would it not show up? Do you have it inside UIButton?
  1.         /// <summary>
  2.         /// Whether the sprite changes will elicit a call to MakePixelPerfect() or not.
  3.         /// </summary>
  4.  
  5.         public bool pixelSnap = false;
And yes, I've already changed the pixel snap to be 'false' in the Pro version.

Ugur

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 60
    • View Profile
Re: pixelsnap on uibutton is total nonsense
« Reply #6 on: March 02, 2014, 11:17:22 PM »
"Curious. Why would it not show up? Do you have it inside UIButton?"

yeah, hm, maybe the editorscript didn't get the update properly, not sure.

"And yes, I've already changed the pixel snap to be 'false' in the Pro version."


cool, thanks =)