How does Rect work? How can I see it on my screen? How do I display it? Please help!
,Please help me out. I have been trying to get a rectangle to show up for hours! How does it work?
First if you want to draw a rectangle by using rect you cannot do it on Update or Start you need to use some functinos like OnGUI or OnInspectorGUI. Also, unless you didn’t write an editor script it should be seen only when you hit the play button. There is the script wrote:
using UnityEngine;
public class RectangleDrawer : MonoBehaviour
{
public float width, height;
public float X, Y;
// Start is called before the first frame update
void OnGUI()
{
GUI.Box(new Rect(X, Y, width, height), "A rectangle");
}
// Update is called once per frame
void Update()
{
}
}
Please feel free to ask any questions if you want anything else and hope this helps.