GUI.Button not showing up in Unity Game tab

Hi all,

I’m very new to Unity, and I seem to be having an issue with the GUI.Button function - I can’t get it to show up. I copy/pasted the code from this page to try and test it out, but no button is showing up at all while I’m in the Unity editor, Game tab.

Here’s the code I have:

using UnityEngine;
using System.Collections;

public class GUI_Test : MonoBehaviour {

    void OnGUI () {
        if (GUI.Button (new Rect (10, 10, 150, 100), "Here goes.")) {
            print ("Click.");
        }
    }
}

What am I doing wrong here? I hardly think the example is wrong, maybe I’m just overlooking something?

Attach it to a GameObject in your scene