Search Unity

'Button' is not a member of GUI

Discussion in 'Immediate Mode GUI (IMGUI)' started by wilkinnh, Apr 18, 2008.

  1. wilkinnh

    wilkinnh

    Joined:
    Mar 7, 2008
    Posts:
    14
    Does anyone know what that error message means? I've tried creating a new Unity project and just making a really really really simple GUI command, and this is the error that I get while Unity is trying to compile the code. My code looks like this:

    function OnGUI () {
    GUI.Button (Rect (25,25,100,30), "test");
    }
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Your script is called GUI. So it's trying to find a function in your script called Button, which naturally doesn't exist...easiest thing is to rename your script so it doesn't conflict with a Unity class.

    (This sort of thing happens often enough that maybe UT ought to do some kind of warning....)

    --Eric
     
  3. wilkinnh

    wilkinnh

    Joined:
    Mar 7, 2008
    Posts:
    14
    wow...:oops:

    i never even thought of that, but you're totally right. Thanks!