- Home /
Simulate a button press with GUILayout
Hello! I'm trying to write some playmode tests, but I'm not sure how to go about simulating a button press when using GUILayout.Button(). Does anyone know how it works?
// Create "Load Project" Button and define onClick action
if (GUILayout.Button("Load Project", GUILayout.Height(40)))
{
// Do something when button is pressed
}
Comment
Answer by Lawlets · Jan 17, 2020 at 09:13 AM
Currently, your code should work. Is your if(GUILayout.Button("Load Project", GUILayout.Height(40))) {}
is inside the void OnGUI()
function ?
Try to do the same thing that the code example in the Unity documentation