Definition
SelectPrefabInstances(double mousePositionX, double mousePositionY, double selectionWidthSize, double selectionHeightSize)
Description
This function selects selectable prefab instances. For this function to work, in prefab mode, through the Modify > Prefab Properties menu, make sure the Selectable option is checked for the desired prefab.
Parameters
mousePositionX, mousePositionY
Specify the center of a selection region in window coordinates.
selectionWidthSize, selectionHeightSize
Specify the width and height, respectively, of the selection region in window coordinates.
Example
function Init() LoadResource("images", "cursor.dds") ShowCursorIcon("images_cursor.dds", 5.0) end function Update() if IsKeyDown("0") then SelectPrefabInstances(GetCursorX(), GetCursorY(), 20.0, 20.0) end end
First, we load and display cursor.dds resource image (In order for LoadResource function to load the desired resource, you must first add it through the Add Resource to Current Project dialog (File > Project > Add/Remove Resource to/from Current Project). Then, in the Update() event, in the SelectPrefabInstances function, we set the center of the selection to the mouse position using GetCursorX() and GetCursorY() functions and set the length and width of the selection to 20.0. Whenever the user left-clicks, the SelectPrefabInstances function is called. If the prefab instance is in the selection region, it is selected and its Onselect() event is called.
SelectPrefabInstances