Как тот так (AlignGUITexture.cs):
using UnityEngine;
[RequireComponent(typeof(GUITexture))]
public class AlignGUITexture : MonoBehaviour
{
public Alignment alignment;
public enum Alignment
{
None,
LeftUp,
LeftDown,
RightUp,
RightDown
}
public float offsetX;
public float offsetY;
public float width;
public float height;
public int defaultScreenHeight = 768;
public bool correctSize = true;
void Reset()
{
if(guiTexture)
{
width = guiTexture.pixelInset.width;
height = guiTexture.pixelInset.height;
}
}
void Start()
{
float x = offsetX;
float y = offsetY;
float w = width;
float h = height;
if (correctSize)
{
var scale = (float)Screen.height/defaultScreenHeight;
x *= scale;
y *= scale;
w *= scale;
h *= scale;
}
switch (alignment)
{
case Alignment.None:
break;
case Alignment.LeftUp:
transform.position = new Vector3(0, 1, transform.position.z);
guiTexture.pixelInset = new Rect(x, -h - y, w, h);
break;
case Alignment.LeftDown:
transform.position = new Vector3(0, 0, transform.position.z);
guiTexture.pixelInset = new Rect(x, y, w, h);
break;
case Alignment.RightUp:
transform.position = new Vector3(1, 1, transform.position.z);
guiTexture.pixelInset = new Rect(-x - w, -h - y, w, h);
break;
case Alignment.RightDown:
transform.position = new Vector3(1, 0, transform.position.z);
guiTexture.pixelInset = new Rect(-x - w, y, w, h);
break;
}
}
}