The problem was that i had the first two variables in the rect set to 25 which meant it was 25 times the camera height and width and when i changed that to .5 it worked. Here is my final code(the GUI.backgroundcolor = Color.Clear is to make the buttns invisible):
using UnityEngine;
using System.Collections;
public class ButtonScript : MonoBehaviour {
public Texture2D icon;
public float posX;
public float posY;
public string LevelToLoad;
// Use this for initialization
void Start () {
}
void OnGUI()
{
GUI.backgroundColor = Color.clear;
if (GUI.Button (new Rect (Screen.width * posX, Screen.height * posY, 200, 40), icon)) {
Application.LoadLevel (LevelToLoad);
}
}
// Update is called once per frame
void Update () {
}
}
↧