basic rectangle

sorry in advance for the absolutely basic question. but i’ve got to start somewhere, and the holes in my knowledge of scripting and basic implementation are staggeringly large.

i’m trying to draw a rectangle on screen, from the basic camera view

so

using UnityEngine;
using System.Collections;

public class MenuTry : MonoBehaviour {
	public Rect Rect = new Rect(10, 10, 100, 100);
}

and you drag that over onto the inspector panel for main camera… right?

but then how do you implement it. I built it, started the game, and nothing popped up. do I have to make a function to call it… or what? again, sorry for the stupid basic question, but this is the shit that’s assumed by every tutorial out there yet never mentioned. for whatever reason.

Yeah all GUI that you want displayed should go under function OnGUI. In your case, you’d basically have to do something like this :

var Width = 100;
var Height = 100;

function OnGUI(){
//all your GUI code goes here
GUI.Box(Rect (Screen.width / 2 - 50, Screen.height / 2 - 50, Width, Height),"");
}

You should have a small square at the center of your screen when you hit play. You can adjust the width height by tweaking the variables whilst in game mode.