Buttons and Rect

Hi,

i read somewhere that a lot of buttons slow you heavily down and creating a buttonclass on your own is the better way to go.
Is that true? link: How can I create an Inventory system with GUI? - Questions & Answers - Unity Discussions

anothe thing is that when i used this code like this, unity creates my rect by default in the bottom left corner insted top left.
why?

using UnityEngine;
using System.Collections;

public class __GameMaster : MonoBehaviour {
	Rect rect;
	void Awake () {
    DontDestroyOnLoad (gameObject);
	}

	// Use this for initialization
	void Start () {
		rect = new Rect(0, 0, 150, 150);
	}
	
	// Update is called once per frame
	void Update () {
	        
        if (rect.Contains(Input.mousePosition))
            print("Inside");
		else
			print ("outside");
        
    }
	
}// this code creates a rect in top left, and prints if mouse is inside or not.

Greets Equal

I’ve never known buttons to slow down a game by any significant amount. (Hell, my current program is nothing but a ton of buttons, and it runs just fine.)

As to your location problem, I’m assuming it has something to do with the mouse position. (While most coordinates use 0,0 as the upper left, for some reason, the mouse’s 0,0 is the lower left.)

Input.mousePosition returns screen coordinates, which are bottom-up. OnGUI code uses GUI coordinates, which are top-down, rather than screen coordinates. You would use Event.current.mousePosition inside OnGUI to get the mouse position in GUI coordinates.

–Eric

Thanks alot guys!
As always helpful.