Definition
SetSelectionDistance(float selectionDistance)
Description
This function sets the maximum distance from the camera that you can select a prefab instance using the SelectPrefabInstances function.
Parameter
selectionDistance
Sets the maximum distance from the camera that you can select a prefab instance using the SelectPrefabInstances function. This value must be greater than 0.0.
Example
function Init() LoadResource("images", "cursor.dds") ShowCursorIcon("images_cursor.dds", 5.0) SetSelectionDistance(5.5) end function Update() if IsKeyDown("0") then SelectPrefabInstances(GetCursorX(), GetCursorY(), 20.0, 20.0) end end
First, in the Init() event, we load and show resource cursor icon “cursor.dds” located in “images” folder (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 we set the maximum distance for selection to 5.5 using the SetSelectionDistance function. 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 and its distance from camera is less than 5.5 units, it is selected and its Onselect() event is called.
SetSelectionDistance