My GUI.Label does not work and I do not know what to do.

This code is attached to a square sprite. I have no other scripts. I am trying to get GUI.Label to work for future use. It does not display the text.

using System;
using UnityEngine;

public class SquareScript : MonoBehaviour
{
    //float accel = 1f;

    void Start()
    {
        //transform.position = new Vector3(1, 0);
    }

    void Update()
    {
        //transform.position = new Vector3((float)Math.Cos(Math.Pow(Time.time, 2) * accel / 2), (float)Math.Sin(Math.Pow(Time.time, 2) * accel / 2));
    }

    void OnGUI()
    {
        GUI.Label(new Rect(-1f, -1f, 2f, 2f), "Where is the text?");
    }

}

By the way I get this warning but I had problems before having this warning so I doubt it has anything to do with this. I should probably put this second part in a seperate question, but because there is a slight chance it might have something to do with this I will include it here.

Unable to find player assembly: C:\Users\User\My project\Temp\StagingArea\Data\Managed\UnityEngine.TestRunner.dll
UnityEngine.Debug:LogWarning (object)
Unity.Burst.Editor.BurstAotCompiler:OnPostBuildPlayerScriptDLLsImpl (UnityEditor.Build.Reporting.BuildReport) (at Library/PackageCache/com.unity.burst@1.6.6/Editor/BurstAotCompiler.cs:350)
Unity.Burst.Editor.BurstAotCompiler:OnPostBuildPlayerScriptDLLs (UnityEditor.Build.Reporting.BuildReport) (at Library/PackageCache/com.unity.burst@1.6.6/Editor/BurstAotCompiler.cs:208)
UnityEditor.BuildPlayerWindow:BuildPlayerAndRun ()

Isn’t that going to give you a 2 pixel by 2 pixel rect that’s centered on the top-left corner of the screen?

Are you trying to say that it is too small to have text or something?

Yes. All of the GUI methods work in GUI Space. (0,0) is the top left corner, and the bottom right corner is (screenWidth, screenHeight).

You should see the text if you do something like GUI.Label(new Rect(0, 0, 500, 500), “Hello!”)

Do you want a piece of text to appear next to the sprite? If so, I would just use a TextMeshPro object parented to the sprite.

Wait so the coordinates are monitor coordinatones and not unity coordinates? That makes so much sense!

Here’s the correct forum for UI questions: Unity Engine - Unity Discussions

I’l move your post.