Screen Placement
The EZScreenPlacement component (found in the Components menu under EZ GUI->Utility->EZ Screen Placement) provides a way to position objects in the scene in a manner that is independent of screen resolution or aspect ratio.EZScreenPlacement allows you to specify that an object (including a non-EZ GUI object) should be placed in the scene either relative to one of the screen's edges, the screen center, or relative to another object in the scene. The distances from each of these frames of reference are given in pixel units. For example, you can tell an object to position itself 10 pixels from the left edge of the screen, and 10 pixels down from the top of the screen, regardless of resolution or aspect ratio.
NOTE: For performance reasons, this component does not update every frame, so if the resolution changes, or an object moves that is set as the "Relative Object", the EZScreenPlacement component will not automatically update the object's position. If one of these events occurs, or for any other reason you want the object to recompute its position on-screen, simply call the component's PositionOnScreen() method, or its SetCamera() method. In addition to these, if SetCamera() is called on a sprite-based EZ GUI object, any attached EZScreenPlacement component will automatically be called as well.
Using EZScreenPlacement
Calling from script The most important methods available via script are the PositionOnScreen() methods, which allow you to re-position the object by specifying new coordinates for the screenPos setting. If you alter any of the relativeTo values at runtime, call PositionOnScreen() to apply them. More information about all the available methods, as well as details on their use, can be found in the scripting reference. |