Definition
int,int GetGUIButtonPosition(string GUIName, string buttonName)
Description
This function returns the two-dimensional position of the button buttonName of GUI GUIName relative to the lower left part of the screen as two x, y values. You can view and copy the name of the GUIs and their buttons in the Script Utility section (Tools > Script Editor > Tools > Script Utility) or the Prefabs and GUIs section of the current VScene.
Parameters
GUIName
The name of the GUI to which the buttonName button belongs.
buttonName
The name of the button that belongs to GUIName.
Return Value
Two-dimensional position of the button buttonName of GUI GUIName relative to the lower left part of the screen as two x, y values.
Example
x = 0 y = 0 function OnSelectMouseLButtonDown() x,y = GetGUIButtonPosition("gui_test_test", "PlayGame") message = string.format("\nGUI button position is > %d, %d" , x,y) PrintConsole(message) end function OnSelectMouseRButtonDown() end function OnSelectMouseEnter() end
Assume that this script is attached to a button named ShowPosition that belongs to a GUI named gui_position. In this case, whenever you left click on the ShowPosition button, the GetGUIButtonPosition function returns the 2D position of the “PlayGame” button from the GUI named “gui_test_test”. This script then displays the x and y positions on the console.
GetGUIButtonPosition