- Home /
Button is not a member of GUI?
alright so i just started making a simple GUI script for my own testing purposes, and for some reason when i run this script:
function OnGUI () {
if(GUI.Button(Rect(10,10,100,50),"Pillar")){
print("Pillar Selected");
}
if(GUI.Button(Rect(10,60,100,50),"Wall")){
print("Wall Selected");
}
}
it refuses to work, i get an error saying: "BCE0019: 'Button' is not a member of 'GUI'." what am i missing?
Answer by Larry-Dietz · Apr 28, 2010 at 09:52 PM
My best guess is that you have a script named GUI, and your code is trying to find a Button method in this script.
If I am right, just rename your script to something other than GUI and it should work just fine.
-Larry
another thing is you might have gotten lazy (like i just did) and ins$$anonymous$$d of OnGUI, you just put GUI. so... OnGUI!
Answer by khalil · Apr 29, 2010 at 12:52 AM
You may also go to Assets > create >GuiSkin and attactch your script to your GUI skin. Hope this works.