SetGUIImagePosition

Definition

SetGUIImagePosition(string GUIName, string imageName, int x, int y)

Description

This function sets the two-dimensional position of the image imageName 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 images 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 imageName image belongs. You can also use the name “this” for this parameter. In this case, the name “this” refers to the GUI to which the image imageName belongs.

imageName
Specifies the the name of the image that belongs to GUIName.

x, y
Specify the two-dimensional position of the image imageName of GUI GUIName relative to the lower left part of the screen as two x, y values.

Example 1

function Init()
   SetGUIImagePosition("gui_SampleGUI17_MainMenuAbout""backgroundImg"GetScreenWidth() / 2, GetScreenHeight() / 2)
end

function Update()

end
In this example, SetGUIImagePosition function sets the X and Y components of 2D position of the “backgroundImg” image from the GUI named “gui_SampleGUI17_MainMenuAbout” to (screen width / 2) and (screen height / 2), respectively.

Example 2

--Name of script is SetGUIImagePosition2.lua

function OnSelectMouseLButtonDown()
    SetGUIImagePosition("this""backgroundImg"GetScreenWidth() / 2, GetScreenHeight() / 2)
end

function OnSelectMouseRButtonDown()

end

function OnSelectMouseEnter()

end
Assume that the above script named SetGUIImagePosition2.lua is attached to a button named “PlayGame” that belongs to the GUI “gui_1”. Also assume that the GUI  “gui_1” has an image named “backgroundImg”. In this case, “this” string in the SetGUIImagePosition function refers to the name “gui_1”. Whenever the user left clicks the “PlayGame” button, we set the X and Y position of the image “backgroundImg” belonging to current GUI, which is GUI “gui_1”, to (screen width / 2) and (screen height / 2), respectively.
adminSetGUIImagePosition