- Home /
Nothing happens when clicking button
I am following the BurgZergArcade tutorial and I ran in to a problem at video 138. The video is very old so I thought it might be a bigger chance to get an answer here. My problem is that I have button in an if statement and it is clickable and all but nothing happens. This is how it looks:
public void DisplayEquipment() {
//Debug.Log ("Eqiupment");
if(PlayerCharacter.EquipedWeapon == null){
GUI.Label(new Rect(5,100,40,40), "", "Inventory Slot Empty");
}
else
{
if(GUI.Button(new Rect(5,100,40,40),new GUIContent(PlayerCharacter.EquipedWeapon.Icon, PlayerCharacter.EquipedWeapon.ToolTip ())))
{
Debug.Log ("Clicked Inventory");
PlayerCharacter.Inventory.Add(PlayerCharacter.EquipedWeapon);
PlayerCharacter.EquipedWeapon = null;
}
}
SetToolTip();
}
I put the Debug.Log there to see if the button actually does anything when clicked but it does not. Any one has any idea?
Have played around a bit and I can add that this button is within a a window with ToolBar and I now tried to remove the DragWindow function and the button works now. Problem not though is of course that the window can not be dragged around. Hopefully now someone will know what is wrong. The code for the window looks like this:
private void CharacterWindow(int id)
{
//GUI.DragWindow();
_characterPanel = GUI.Toolbar (new Rect(5,25,_characterWindowRect.width - 10, 25), _characterPanel,_characterPanelNames);
switch(_characterPanel)
{
case 0:
DisplayEquipment();
break;
case 1:
DisplayAttributes();
break;
case 2:
DisplaySkills();
break;
}
}
Answer by Ragee · Sep 04, 2013 at 11:35 AM
Figured it out now. The GUI.DragWindow() needs to be after the switch. Now everything works as it should. Hope this helped someone :)
Your answer
Follow this Question
Related Questions
Move GUI elements. 0 Answers
Using GUI and check what button was pressed 1 Answer
GUI Button Disappearing 1 Answer
GUI Button for Android 1 Answer
GUI Button to create another GUI 1 Answer