Search Unity

2D objects on screen

Discussion in 'Scripting' started by HersheyZombie, Apr 22, 2008.

  1. HersheyZombie

    HersheyZombie

    Joined:
    Feb 20, 2008
    Posts:
    5
    I am placing 2D pictures and text in my game (GUItextures and GUItexts).
    I can adjust the placement of these based off of distance from the center with their X and Y values, but would like to be able to always place them in the same area of the screen regardless of screen size. How can I test the screen size to make these adjustments or what is a better way to place these objects so they always appear in the corner, etc..
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    GUIElements use normalized coordinates, so they are always in the same relative position no matter what the screen size is. For X, 0 = left edge, 1 = right edge, and for Y, 0 = bottom edge, 1 = top edge.

    --Eric
     
  3. StarManta

    StarManta

    Joined:
    Oct 23, 2006
    Posts:
    8,775
    To expand on that, learn to use both the transform's position scale, and the pixelInset to get exactly what you want. If you want it anchored to one corner but 50 pixels from the side, use the transform to anchor it to the corner and the pixelInset to specify 50 pixels over....

    Takes some practice to get used to.