I have a 2D UI with the scaling style set to FixedSizeOnMobiles and ManualHeight = 640, Minimum Height = 640, and MaximumHeight = 1600. My main target resolutions are iPhone4s, iPhone5 and iPad but I've designed the UI in the 4s resolution.
I've setup a sprite on an
initial position in the screen and I've scaled it down to an
initial size. What I want to do is create a
tween where:
from: dimensions = original width and height && position = center of screen
to: dimensions = initial width and height && position = initial position
I've attached a TweenPosition, a TweenWidth and a TweenHeight on the UISprite and I'm setting the from and to values programatically.
To get the original dimensions I use: sprite.GetAtlasSprite().width and sprite.GetAtlasSprite().height
To get the initial dimensions I use: sprite.width and sprite.height
To get the initial position I use: sprite.transform.localPosition
The problem:
The initial dimensions and position that I get back are always the ones from the 4s resolution and are wrong in the other resolutions (they do not correspond to the values displayed in the editor).
In order to solve the dimensions problem I've used:
sprite.width / UIRoot.GetPixelSizeAdjustment(sprite.gameObject) and sprite.height / UIRoot.GetPixelSizeAdjustment(sprite.gameObject)
as recommend here:
http://www.tasharen.com/forum/index.php?topic=5483.0.
How do I get the correct position though?