Author Topic: UISprites not anchoring / scaling properly on android phone  (Read 4677 times)

gateian

  • Guest
UISprites not anchoring / scaling properly on android phone
« on: December 03, 2012, 04:05:53 PM »
I've been using NGUI for a few weeks now and it's pretty good. Definitely liking the draw call reduction and ease of putting 2D HUD items on screen.

However i'm having a very annoying problem with it when publishing to android. I've anchored some graphics to the bottom right of the screen and they appear in the correct place in the game window. They also stay anchored when I resize this window.

However, when i publish to android. They are not there at all.

Also, i've got some transition graphics that are meant to cover the entire screen in an animation. I used the UIStretch to make sure they always cover the screen, however again on the android version, I get gaps on the sides of these graphics. No idea why it's scaling wrongly. Almost as if my phone is reporting back an incorrect resoltuion or something.

Any ideas?

gateian

  • Guest
Re: UISprites not anchoring / scaling properly on android phone
« Reply #1 on: December 03, 2012, 04:40:29 PM »
On greater examination. It looks like it is the same on my pc after all. Did not realise my phone's resolution was so high. Obviously I have not got my head around the stretching behaviours yet.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UISprites not anchoring / scaling properly on android phone
« Reply #2 on: December 04, 2012, 02:49:39 AM »
Is your UIRoot set to manual mode? If so, I think this is one of the issues fixed in 2.0.7.

gateian

  • Guest
Re: UISprites not anchoring / scaling properly on android phone
« Reply #3 on: December 04, 2012, 01:47:20 PM »
Well the UIRoot has automatic checked, so I imagine not.

It all seems ok now. I think I had it all set up incorrectly, but I've got things scaling and anchoring as I expect them. All except the screen transition, which I think is a problem with the animation system rather than NGUI.

The screen transition consists of 5 black sprites that act as columns lined up next to each to fill the screen. So you get a black screen. If i resize the screen like this, then they will continue to cover the screen no matter what resolution I use. That's how I expect it to work.

However, i've animated these panels to move one by one offscreen to give a bit of a funky look to the transition. I've done that by animating the position of the panels. So each x position is keyframed at the right time. The problem is, that I think these x positions are going to be different depending on the screen resolution because at a higher resolution, my panels begin to overlap each other.

I may have to tackle this by manually coding them. hmm.

gateian

  • Guest
Re: UISprites not anchoring / scaling properly on android phone
« Reply #4 on: December 04, 2012, 03:17:49 PM »
Just thought i'd further post on this in case anyone else is having this problem.

OK, i've found a solution to this problem. Before, I had each of the mentioned panels anchored and UIStretched individually. While the stretching worked ok, anchoring, while trying to animate them was the obvious mistake. So I created a parent object for all the objects and achored that instead.

Problem was that I was still having problems animating the x positions of the panels as they would be different depending on the screen resolution. So id' get gaps in the panels and all sorts.

Of course then I realised how to fix it. I applied the UIStetch to the parent object it and set it to both so that the parent object stretched across the whole screen. That meant my panels could be placed using screen relative positioning of 0 - 1. Now it does not matter what screen resolution it is the. The panels will always animate and cover the screen as wanted.  8)

This is probably the obvious solution, but I was clearly having trouble getting my head around it.

On to the next challenge!