Author Topic: I'm losing pixel-perfect on mobile  (Read 13771 times)

g1i1ch

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 6
    • View Profile
I'm losing pixel-perfect on mobile
« on: October 02, 2014, 06:10:51 PM »
Hey guys, I'm pretty sure I'm doing something wrong here. It doesn't look like I'm getting pixel perfect in ngui.

I'm making a pretty simple game. It's a top down runner type of game. The main element is 1 little sprite and a model that follows it around the screen. The model is the player. The idea is to move the player by dragging around the sprite. The game is played in portrait mode.

I have UIRoot set to flexible with min-height set to 400 and the max-height set to 1500.

Now the issue. I have the control sprite positioned at the start to 1/4 of the screen.height down. (Can't use an anchor because it needs to be dragged) The device has a screen size of 888 (accounting for the bar at the bottom). So it positions the sprite at -222. All is good, but for some reason that's outside of view.

Eventually I got it to show by placing it 1/6 of the way down instead. But when I drag it the sprite moves faster than my finger, like the ui isn't pixel perfect.

Now the weird part, it's working 100% perfect in the editor. Dragging is working good and resizing is positioning the sprite correctly. It's absolutely driving me mad. NGUI is acting like it's zoomed in or something...

Anybody come across this before?

[also] I've also tested it on a nexus tablet and the same thing is happening.
« Last Edit: October 02, 2014, 06:19:36 PM by g1i1ch »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: I'm losing pixel-perfect on mobile
« Reply #1 on: October 02, 2014, 11:03:58 PM »
Have you tried simply printing Screen.width and Screen.height values to see what you get in there?

mplaczek

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 14
    • View Profile
Re: I'm losing pixel-perfect on mobile
« Reply #2 on: October 03, 2014, 09:05:29 AM »
I seem to be having a similar problem. I'm using an iPhone 6 and iPad 4th ten to test on. I only have a few sprites and buttons added to my scene and I'm using a flexible layout with adjust to dpi selected.
To troubleshoot I have been printing the screen height and width, an onscreen UIButton height and width and the UIRoot Scale.
The scene looks perfect in the editor, but as g1i1ch said, on the actual device the UI looks zoomed and is not pixel perfect. The printed UIRoot scale: print(UIRoot.transform.scale) is a little odd in each case,  is that statement correct?

Example of the readouts on the editor:
UIRoot Scale: (0.0, 0.0, 0.0)
Screen height: 705
Screen width: 397
Button height: 70
Button width: 180

Here are the readouts on the iPhone 6:
UIRoot Scale: (0.0, 0.0, 0.0)
Screen height: 1136
Screen width: 640
Button height: 70
Button width: 180

Here are the readouts on the iPad 4th gen:
UIRoot Scale: (0.0, 0.0, 0.0)
Screen height: 2048
Screen width: 1536
Button height: 70
Button width: 180

The UIButtons size seems intact, but physically, it almost takes up the entire screen width on the iPhone.

If there is anything else you can think of trying, or anything else I should print to get more information, please do not hesitate to ask. I'm using NGUI 3.7.3
« Last Edit: October 03, 2014, 02:11:02 PM by mplaczek »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: I'm losing pixel-perfect on mobile
« Reply #3 on: October 04, 2014, 07:56:36 AM »
UIRoot scale of 0 means nothing is visible. Scale of zero is invalid. What made it zero?

mplaczek

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 14
    • View Profile
Re: I'm losing pixel-perfect on mobile
« Reply #4 on: October 04, 2014, 11:32:49 AM »
I'm not sure... I've tested on a new project and I get the same result.
New project... install Ngui 3.7.4... add a button to the scene from your prefab toolbar attach a script to the camera that prints UIRoot.transform.localScale.
The result is (0.0, 0.0, 0.0)
g1i1ch... are you using Unity 4.6? Perhaps this issue is not NGUI related?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: I'm losing pixel-perfect on mobile
« Reply #5 on: October 05, 2014, 08:57:54 AM »
Unity 4.5.4. What do you get from NGUITools.screenSize?

mplaczek

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 14
    • View Profile
Re: I'm losing pixel-perfect on mobile
« Reply #6 on: October 06, 2014, 01:22:46 AM »
Hi ArenMook,

I'm getting the same results as the screen width and screen height... Which I assume is what you would expect.
NGUITools.screenSize running on the iPhone 6 prints: (640.0, 1136.0)

LightStorm

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 17
    • View Profile
Re: I'm losing pixel-perfect on mobile
« Reply #7 on: October 06, 2014, 03:02:20 AM »
Hi All.
I think it's because Unity 4.54 don't support iPhone 6 and iPhone 6 Plus.
Check this:
Quote
Improvements

    Linux: Implement screen-fullscreen command line option.
    OSX: Implement show-screen-selector command-line option.
    iOS: Added iPhone 6 & iPhone 6 Pl.
here - http://unity3d.com/unity/qa/patch-releases in Patch 4.5.4p1 release.


mplaczek

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 14
    • View Profile
Re: I'm losing pixel-perfect on mobile
« Reply #8 on: October 06, 2014, 03:23:39 AM »
I also have the same problems on my iPad 4th gen not just the iPhone 6. Could it be an iOS 8 issue?

LightStorm

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 17
    • View Profile
Re: I'm losing pixel-perfect on mobile
« Reply #9 on: October 06, 2014, 08:04:41 AM »
I also have the same problems on my iPad 4th gen not just the iPhone 6. Could it be an iOS 8 issue?
I think you should try to install latest Unity patch release and try to test this with it. Latest patch release is: "Patch 4.5.4p3 Released: 3 October 2014"

mplaczek

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 14
    • View Profile
Re: I'm losing pixel-perfect on mobile
« Reply #10 on: October 06, 2014, 08:10:56 AM »
Happily...
I'll report back...
« Last Edit: October 06, 2014, 09:48:40 AM by mplaczek »

mplaczek

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 14
    • View Profile
Re: I'm losing pixel-perfect on mobile
« Reply #11 on: October 07, 2014, 05:39:22 AM »
Hi Lightstorm,

Yes, Downgrading to 4.5.4 seems to have resolved the problems I was having. The default scenes that ship with NGUI worked perfectly, so I knew I was on the right track... In one or two of my scenes I needed some additional tweeting of my settings to get everything perfect... probably the result of me messing around to get it to work previously.

Thank you for your help.

I apologise for hijacking the thread a little, I hope what has been shared will also help the OP!