Search Unity

how to stretch a guiTexture to fill screen?.

Discussion in 'Immediate Mode GUI (IMGUI)' started by spaceMan-2.5, May 10, 2011.

  1. spaceMan-2.5

    spaceMan-2.5

    Joined:
    Oct 21, 2009
    Posts:
    710
    Hi..

    i know how to stretch a texture but now i´m trying to detect the screen limits for a guiTexture that contains an animation of vertical movement.

    is there a way?


    Thanks. !
     
  2. alverndbl

    alverndbl

    Joined:
    Jul 11, 2010
    Posts:
    25
    I think you need this the Screen.height and Screen.width reads the screen height and width
     
  3. Tom163

    Tom163

    Joined:
    Nov 30, 2007
    Posts:
    1,290
    This is a small script I use to rescale background textures. It only works properly if the aspect ratio doesn't change, but it should be easy to adapt it:
    Code (csharp):
    1.  
    2. function Start() {
    3.     guiTexture.pixelInset.width = Screen.width;
    4.     guiTexture.pixelInset.height = Screen.height;
    5.     guiTexture.pixelInset.x = -Screen.width/2;
    6.     guiTexture.pixelInset.y = -Screen.height/2;
    7. }
    8.  
    You may also have to put your texture at the 0.5 / 0.5 coordinates, but since that's the default anyways... don't know if it works if you don't.
     
  4. spaceMan-2.5

    spaceMan-2.5

    Joined:
    Oct 21, 2009
    Posts:
    710
    perfect ;) thanks for that last code thanks both 1º1