Class SelectionPicker
Functions for picking mesh elements in a view. Can either render a texture to test, or cast a ray. Prefer this over calling SelectionPickerRenderer directly.
Namespace: UnityEngine.ProBuilder
Syntax
public static class SelectionPicker
Methods
PickEdgesInRect(Camera, Rect, IList<ProBuilderMesh>, PickerOptions, Single)
Pick the edges contained within a rect.
Declaration
public static Dictionary<ProBuilderMesh, HashSet<Edge>> PickEdgesInRect(Camera cam, Rect rect, IList<ProBuilderMesh> selectable, PickerOptions options, float pixelsPerPoint = 1F)
Parameters
Type | Name | Description |
---|---|---|
Camera | cam | |
Rect | rect | Rect is in GUI space, where 0,0 is top left of screen, width = cam.pixelWidth / pointsPerPixel. |
IList<ProBuilderMesh> | selectable | The ProBuilder mesh objects to consider when hit testing. |
PickerOptions | options | Culling options. |
Single | pixelsPerPoint | Scale the render texture to match rect coordinates. Generally you'll just pass in EditorGUIUtility.pointsPerPixel. |
Returns
Type | Description |
---|---|
Dictionary<ProBuilderMesh, HashSet<Edge>> | A dictionary of ProBuilderMesh and edges that are in the selection rect. |
PickFace(Camera, Vector3, ProBuilderMesh)
Returns the first hit face on a ProBuilder mesh given a screen position and camera.
Declaration
public static Face PickFace(Camera camera, Vector3 mousePosition, ProBuilderMesh pickable)
Parameters
Type | Name | Description |
---|---|---|
Camera | camera | The camera to use when calculating the raycast. |
Vector3 | mousePosition | The screen position to use when calculating the raycast. |
ProBuilderMesh | pickable | The ProBuilderMesh to test for ray/face intersection. |
Returns
Type | Description |
---|---|
Face | A Face if successful, null if the hit test failed. |
PickFacesInRect(Camera, Rect, IList<ProBuilderMesh>, PickerOptions, Single)
Pick faces contained within rect.
Declaration
public static Dictionary<ProBuilderMesh, HashSet<Face>> PickFacesInRect(Camera cam, Rect rect, IList<ProBuilderMesh> selectable, PickerOptions options, float pixelsPerPoint = 1F)
Parameters
Type | Name | Description |
---|---|---|
Camera | cam | |
Rect | rect | Rect is in GUI space, where 0,0 is top left of screen, width = cam.pixelWidth / pointsPerPixel. |
IList<ProBuilderMesh> | selectable | |
PickerOptions | options | |
Single | pixelsPerPoint | Scale the render texture to match rect coordinates. Generally you'll just pass in EditorGUIUtility.pixelsPerPoint. |
Returns
Type | Description |
---|---|
Dictionary<ProBuilderMesh, HashSet<Face>> |
PickVerticesInRect(Camera, Rect, IList<ProBuilderMesh>, PickerOptions, Single)
Pick the vertex indexes contained within a rect.
Declaration
public static Dictionary<ProBuilderMesh, HashSet<int>> PickVerticesInRect(Camera cam, Rect rect, IList<ProBuilderMesh> selectable, PickerOptions options, float pixelsPerPoint = 1F)
Parameters
Type | Name | Description |
---|---|---|
Camera | cam | |
Rect | rect | Rect is in GUI space, where 0,0 is top left of screen, width = cam.pixelWidth / pointsPerPixel. |
IList<ProBuilderMesh> | selectable | The objects to hit test. |
PickerOptions | options | Culling options. |
Single | pixelsPerPoint | Scale the render texture to match rect coordinates. Generally you'll just pass in EditorGUIUtility.pointsPerPixel. |
Returns
Type | Description |
---|---|
Dictionary<ProBuilderMesh, HashSet<Int32>> | A dictionary of ProBuilderMesh and sharedIndexes that are in the selection rect. To get triangle indexes access the pb.sharedIndexes[index] array. |