Author Topic: SpriteSelector.cs window Screen.width is incorrect for the window.  (Read 3072 times)

Silverleaf1

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
I have installed the latest version of NGUI as of today (deleted and reimported just to be sure nothing in the install was messed up).
When I click on Sprite on a UISprite widget to go select a sprite for the Atlas, the SpriteSelector window is not auto resizing correctly for me so many of the sprites are scrolled off the right side of the window and not showing and the scrollbars are not working to show the extra content.

I'm currently looking at the code further to diagnose how to fix it and get the window to correctly show all the sprites as this is making it impossible to select some sprites from the atlas for use.

Anyone else getting this?

I'm running Unity 5.4.03 on a Macbook Pro, btw.  Dunno if Mac is having some different behavior for default skin or what?

Thanks.
« Last Edit: August 27, 2016, 04:12:44 AM by Silverleaf1 »

Silverleaf1

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
So, I dug into and debugged the SpriteSelector.cs code and I have found that Screen.Width is reporting an incorrect Width value for the size of the window.
This is not reporting the with of the actual sprite selector window screen size.

I found a function that works better, and here's the fix: (I replaced Screen.width with EditorGUIUtility.currentViewWidth and this worked like a charm!)
HOWEVER: I thought Screen.width is 'supposed' to return the width of the current view if it's currently used inside an active GUILayout, so your code 'should' have worked? But it doesn't. Anyway, my fix makes SpriteSelector now function correctly.
Aaron if you have an even more robust fix than mine, please reply and I'll use that instead, otherwise maybe you can just put in this fix and release it as a bug fix?

Thanks!

         int screenWidth = (int)EditorGUIUtility.currentViewWidth; //Screen.width;
         int columns = Mathf.FloorToInt(screenWidth / padded);
         if (columns < 1) columns = 1;

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: SpriteSelector.cs window Screen.width is incorrect for the window.
« Reply #2 on: August 30, 2016, 07:31:02 PM »
Unity 5.4 changed a bunch of stuff for Retina devices, breaking a whole lot of crap in the process, so yes -- I am guessing its another OSX issue alongside the clicking reporting different screen size. Thanks for letting me know.
« Last Edit: September 03, 2016, 01:57:07 AM by ArenMook »

Silverleaf1

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 3
    • View Profile
Re: SpriteSelector.cs window Screen.width is incorrect for the window.
« Reply #3 on: September 01, 2016, 05:43:26 AM »
If they were actively changing code for Retina, then they should be testing those changes on Retina to see if everything still works.
Sloppy engineering practices on Unity's part.  :-\  Yeah, they really need to get Screen.width functioning properly again for OSX. How annoying.