Basically, I'm trying to make buttons within a panel which, when clicked, create an object which can be dragged and dropped into the world. The button should remove itself from the panel when clicked. Doing this has caused some pretty strange behavior, though:
if (!pickUpFlag && GUI.RepeatButton(new Rect(70,25, 50, 50), "Magic"))
{
pickUpFlag = true;
}
if (!endFlag && GUI.RepeatButton(new Rect(10,85, 50, 50), "End"))
{
endFlag = true;
}
if (!startFlag && GUI.RepeatButton(new Rect(10,25, 50, 50), "Start"))
{
startFlag = true;
}
The above code functions weirdly... clicking either of the first two buttons works fine, however, clicking the last button IN CODE (the start button) causes some issues; Buttons will no longer highlight, and in some circumstances (that I can't replicate) the gui will show one of the other buttons as active/clicked when it is moused over. Additionally, anything in other parts of the code which is supposed to execute on !Input.GetMouseButton(0) won't execute until the mouse button is clicked again. Weird stuff. Any ideas?
NOTE: I am using RepeatButton because you're supposed to drag the item off of the button and release it into the world... a regular Button doesn't return true until I release the mouse button (while mouse is stull on top of it), but RepeatButton returns true as soon as it is pressed. The way it works in my program is: The user presses the mouse button over one of these buttons. When the mouse button is depressed, the button disappears and a graphic/model appears attached to the mouse. That can be dragged and dropped into the world. Regular buttons won't work because they don't return true until I release the mousebutton.