- Home /
Question by
Brett Sim · Mar 22, 2013 at 04:38 PM ·
menuguitexturescreen resolution
Making a GUITexture Menu proportional to screen resolution
I want to make the size of my GUITexture buttons' dimensions about a sixth of the size of my screen's height. Right now, I also want my GUITextures to move relative to the main GUITexture menu stated below. Here's what I have so far:
using UnityEngine;
using System.Collections;
public class InventoryScriptBox : MonoBehaviour
{
public GUITexture texture;
public InventoryScriptMain mainInventory;
float mainX;
float mainY;
public float offsetX;
public float offsetY;
public float width;
public float height;
int screenWidth = Screen.width;
int screenHeight = Screen.height;
float ratioX = Screen.width/5.0f;
float ratioY = Screen.height/5.0f;
public int indexX;
public int indexY;
// Use this for initialization
void Start ()
{
GUI.depth = 3;
mainX = mainInventory.guiTexture.pixelInset.x * ratioX;
mainY = mainInventory.guiTexture.pixelInset.y * ratioY;
texture.guiTexture.pixelInset = new Rect(mainX + offsetX, mainY + offsetY, ratioX, ratioY);
Debug.Log (ratioX + ", " + ratioY);
}
// Update is called once per frame
void Update ()
{
mainX = mainInventory.guiTexture.pixelInset.x;
mainY = mainInventory.guiTexture.pixelInset.y;
texture.guiTexture.pixelInset = new Rect(mainX + offsetX, mainY + offsetY, ratioX, ratioY);
}
void OnMouseDown()
{
//Debug.Log("Mouse Down Box " + indexY + ", " + indexX);
Debug.Log (screenWidth + ", " + screenHeight);
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613094904im_/https://answers.unity.com/themes/thub/images/avi.jpg)