- Home /
Simulate IMGUI button press
Is there a way we can simulate IMGUI button press?
Answer by Bunny83 · Aug 31, 2016 at 12:09 AM
No, because you can't create / queue Events manually. So you would need to use a boolean variable instead. Make sure you put it after the actual button
if (GUILayout.Button("MyButton") && someBool)
{
someBool = false;
// your button code
}
If you want to simulate a button press on a button that isn't yours, you're out of luck with what the Unity API provides. The only way in this case would be to use native code to move the mouse cursor / simulate a mouse click
Was looking for something like this for imgui
buttonvar pointer = new PointerEventData(EventSystem.current); ExecuteEvents.Execute(button.gameObject, pointer, ExecuteEvents.pointerEnterHandler);
Guess the api does not provide anything similar
Your answer
Follow this Question
Related Questions
How to toggle the color of a button? 1 Answer
Making a Hover function for a button or toolbar from code. 2 Answers
GUI messed up after build 0 Answers
Close my GUI button by repressing the same Hot-key. 3 Answers
Load/Change scene with UI Button 1 Answer