GetGUITextPosition

Definition

int,int GetGUITextPosition(string GUIName, string textName)

Description

This function returns the two-dimensional position of the text textName 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 texts 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 to which the textName text belongs.

textName
Specifies the the name of the text that belongs to GUIName.

Return Value

Two-dimensional position of the text textName 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 = GetGUITextPosition("gui_test_test""text1")

    message = string.format("\nGUI text 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 GetGUITextPosition function returns the 2D position of the “text1” text from the GUI named “gui_test_test”. This script then displays the x and y positions on the console.
adminGetGUITextPosition