GetGUIPosition

Definition

int,int GetGUIPosition(string GUIName)

Description

This function returns the X and Y of the GUI GUIName as a percentage of the screen width and height. You can view and copy the name of the GUIs in the Script Utility section (Tools > Script Editor > Tools > Script Utility) or the Prefabs and GUIs section of the current VScene.

Parameters

GUIName
Specifies the name of the GUI.

Return Value

Returns the X and Y of the GUIName as a percentage of the screen width and height. Each of these two values are in the range [-100, 100]. It should be noted that the width of the GUI ranges from -(screen width) to (screen width), or -100 to 100 percents, and the height of the GUI ranges from -(screen height) to (screen height), or -100 to 100 percents. So -100 means (-screen width) or (-screen height) and 100 means (screen width) or (screen height).

Example

x = 0
y = 0

function Init()
    x,y = GetGUIPosition("gui_SampleGUI17_MainMenu")

    message = string.format("\nGUI position is > %d, %d" , x,y)
    PrintConsole(message)
end

function Update()

end
In this example, GetGUIPosition returns the X and Y values as percentages of the screen width and height. For example assume that it returns -5 and 10 percents of the screen width and height, respectively. Also Assume that the width and height of the screen are equal to 1024 and 768 respectively. In this case, these numbers will be equal to (-5 * 1024 / 100 = -51.2) and (10 * 768 / 100 = 76.8) respectively, in screen coordinates.
adminGetGUIPosition