Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: niall on July 25, 2014, 09:41:56 AM

Title: screen coordinates in editor
Post by: niall on July 25, 2014, 09:41:56 AM
I'm reading in some "legacy" animated storybooks, made in a different engine, but with assets that I can at least mess with in Unity.  For now we'll assume only the iPhone 5 resolution of 1136x640, as I can get the assets at other resolutions as well, but I'm prototyping with the iPhone 5. 

For a given book, I pull down some data from a SQL server (via PHP to JSON) that gives me web addresses to download the assets .zip file and data .plist file.  I have handled the extraction and local device storing of this stuff.  So I'm loading book pages and animations using the WWW interface from persistentDataPath, creating NGUI 2D Sprites for them, and dropping them on the screen.  I'm also reading in the .plist into my own internal class structure.  The issue I'm having, in the editor at least, is with the screen coordinates for animations, which are based on this 1136x640 screen resolution.  The editor does not report Screen.width and height at those dimensions, and fullscreen anchored NGUI sprites are also at strange dimensions.  Rather than pulling out the Game window and running it fullscreen on another monitor, I'd like to just do some calculations on current screen width/height vs expected 1136x640, and modify my animation coordinates accordingly, probably just a single floating point scale value?  Where do I get this value, if it exists?  Do I need to have a fullscreen sprite that is anchored to all 4 sides and use the dimensions of that sprite for my screen dimensions?  Surely that value is obtainable by some other means within NGUI?

TLDR: If a sprite needs to be positioned at 100,100 on an 1136x640 screen, how can I ensure it's positioned properly regardless of current screen width/height in the editor's Game view?
Title: Re: screen coordinates in editor
Post by: ArenMook on July 26, 2014, 12:46:27 AM
Easiest method? Use anchoring. Anchor the sprite, using the camera's game object as the target.