This function creates a button control within the current debug section. Clicking the button executes a Function.
The current debug section is the one last created using dbg_section.
NOTE This control takes up a single column and can be shown on the same line with another single-column control using dbg_same_line.
dbg_button(label, ref[, width, height]);
Argument | Type | Description |
---|---|---|
label | String | The text label to show next to the button |
ref | Reference or Script Function or Function | A Function or Script Function or a reference to one (created with ref_create) |
width | Real | OPTIONAL The width of the button in pixels |
height | Real | OPTIONAL The height of the button in pixels |
N/A
Create Event
my_method = function()
{
show_debug_message("Clicked the button!"
};
dbg_button("Click me!", my_method);
The above code creates a button control in an object's Create event using dbg_button. Since no calls are made to dbg_view or dbg_section, the button is added to a new debug section named "Default" in a new debug view named "Default". Clicking the button calls a function that shows a debug message using show_debug_message.
Script Asset
/// Script Asset
function script_function()
{
show_message("Called the script function!");
}
Create Event
my_method = function()
{
show_message("Called the method!");
}
ref_to_method = ref_create(self, "my_method");
ref_to_script_function_global = ref_create(global, "script_function");
func = script_function;
ref_to_script_function = ref_create(self, "func");
dbg_section("Function Calls");
dbg_button("Call the Script Function", script_function, 400);
dbg_button("Call the Script Function through the Reference", ref_to_script_function, 400);
dbg_button("Call the Script Function through the Reference (Global)", ref_to_script_function_global, 400);
dbg_button("Call the Method", my_method, 400);
dbg_button("Call the Method through the Reference", ref_to_method, 400);
dbg_section("Game");
dbg_button("End the Game", game_end);
The code example above shows a variety of ways to add button controls that execute functions to the debug overlay.
First, a script function is defined in a script asset as well as a method in an object's Create event. Then, also in the Create event, various references to the script function and to the method are created. Note that in case of ref_to_script_function, you can change the function to be executed by simply assigning a new value to the instance variable func. After that, two sections are added to the debug overlay. Several buttons are added to the first section, where each of them calls the script function or the method through a different path. One more button is added to the second section. Clicking this button executes the built-in function game_end, which can be called because it takes no (mandatory) arguments.
When the code has executed, The Debug Overlay is shown as any call to the dbg_* functions will bring up the overlay.