How to align a GUI texture with the top left of the screen?

I've been looking through the 3rd person platformer tutorial and it has a good system of aligning your GUI even when the screen resolution changes. I am, however, having issues with trying to figure out how to align the texture in question with the Top Left of the screen (the platformer tutorial aligns with the bottom right or just the bottom of the screen). Does anyone know how to accomplish this? Below is the bit of code that allows for drawing to the bottom right:

    function DrawImageBottomRightAligned (pos : Vector2, image : Texture2D)
{
        var scaledResolutionWidth = nativeVerticalResolution / Screen.height * Screen.width;
        GUI.Label(Rect (scaledResolutionWidth - pos.x - image.width, nativeVerticalResolution - image.height - pos.y, image.width, image.height), image);
}

You don't need to script anything if you know the size of the texture ahead of time.

  1. Set your GUITexture position to (0, 1, 0)
  2. Set your GUITexture pixel inset to (X: 0, Y: -256, Width: 256, Height: 256)

(obviously assumes a 256x256 texture)

What aligns this texture to the top is setting the position's Y component to 1 (the position is in viewport space where 1,1 is top-right). Then, the negative number in the pixel offset will move the texture down.

Hope this helps.

I'm not familiar with the 3d platformer GUI code (The code you've posted looks rather odd, in that the x position is set with the "scaled" resolution, and the y with "native". Why not just use Screen.height and Screen.width directly?)

In any case, the origin is actually located in the top left, so you should just be able to use this:

GUI.Label(Rect(pos.x, pos.y, image.width, image.height), image);

Use this function to position you label/image anywhere you want. You will have to pass in positions between 0 and 1, where 0/0 will be top left corner and 1/1 would be bottom right.

function DrawImageAtRelativePosition (pos : Vector2, image : Texture2D)
{
  var x = pos.x * Screen.width;
  var y = pos.y * Screen.height;
  GUI.Label(Rect (x, y, image.width, image.height), image);
}