Class BoundingBox
BoundingBox allows to transform objects (rotate and scale) and draws a cube around the object to visualize the possibility of user triggered transform manipulation. BoundingBox provides scale and rotation handles that can be used for far and near interaction manipulation of the object. It further provides a proximity effect for scale and rotation handles that alters scaling and material.
Implements
Namespace: Microsoft.MixedReality.Toolkit.UI
Assembly: cs.temp.dll.dll
Syntax
public class BoundingBox : MonoBehaviour, IMixedRealitySourceStateHandler, IMixedRealityFocusChangedHandler, IMixedRealityFocusHandler, IBoundsTargetProvider
Fields
debugText
Declaration
public TextMesh debugText
Field Value
Type | Description |
---|---|
TextMesh |
RotateStarted
Declaration
public UnityEvent RotateStarted
Field Value
Type | Description |
---|---|
UnityEvent |
RotateStopped
Event that gets fired when interaction with a rotation handle stops.
Declaration
public UnityEvent RotateStopped
Field Value
Type | Description |
---|---|
UnityEvent |
ScaleStarted
Event that gets fired when interaction with a scale handle starts.
Declaration
public UnityEvent ScaleStarted
Field Value
Type | Description |
---|---|
UnityEvent |
ScaleStopped
Event that gets fired when interaction with a scale handle stops.
Declaration
public UnityEvent ScaleStopped
Field Value
Type | Description |
---|---|
UnityEvent |
Properties
Active
Flag that indicates if the bounding box is currently active / visible.
Declaration
public bool Active { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
BoundingBoxActivation
Type of activation method for showing/hiding bounding box handles and controls
Declaration
public BoundingBox.BoundingBoxActivationType BoundingBoxActivation { get; set; }
Property Value
Type | Description |
---|---|
BoundingBox.BoundingBoxActivationType |
BoundsOverride
For complex objects, automatic bounds calculation may not behave as expected. Use an existing Box Collider (even on a child object) to manually determine bounds of Bounding Box.
Declaration
public BoxCollider BoundsOverride { get; set; }
Property Value
Type | Description |
---|---|
BoxCollider |
BoxGrabbedMaterial
Material used to display the bounding box when grabbed. If set to null no change will occur when grabbed.
Declaration
public Material BoxGrabbedMaterial { get; set; }
Property Value
Type | Description |
---|---|
Material |
BoxMaterial
Material used to display the bounding box. If set to null no bounding box will be displayed
Declaration
public Material BoxMaterial { get; set; }
Property Value
Type | Description |
---|---|
Material |
BoxPadding
Extra padding added to the actual Target bounds
Declaration
public Vector3 BoxPadding { get; set; }
Property Value
Type | Description |
---|---|
Vector3 |
CalculationMethod
Defines the volume type and the priority for the bounds calculation
Declaration
public BoundingBox.BoundsCalculationMethod CalculationMethod { get; set; }
Property Value
Type | Description |
---|---|
BoundingBox.BoundsCalculationMethod |
CloseGrowRate
Scaling animation velocity from medium to close proximity.
Declaration
public float CloseGrowRate { get; }
Property Value
Type | Description |
---|---|
Single |
CloseScale
A Proximity-enabled Handle scales by this amount when a hand moves into the Close Proximity range. Default is 1.5, larger handle size
Declaration
public float CloseScale { get; set; }
Property Value
Type | Description |
---|---|
Single |
DrawTetherWhenManipulating
Check to draw a tether point from the handles to the hand when manipulating.
Declaration
public bool DrawTetherWhenManipulating { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
FarGrowRate
Scaling animation velocity from medium to far proximity state.
Declaration
public float FarGrowRate { get; }
Property Value
Type | Description |
---|---|
Single |
FarScale
A Proximity-enabled Handle scales by this amount when a hand moves out of range. Default is 0, invisible handle.
Declaration
public float FarScale { get; set; }
Property Value
Type | Description |
---|---|
Single |
FlattenAxis
Flatten bounds in the specified axis or flatten the smallest one if 'auto' is selected
Declaration
public BoundingBox.FlattenModeType FlattenAxis { get; set; }
Property Value
Type | Description |
---|---|
BoundingBox.FlattenModeType |
FlattenAxisDisplayScale
When an axis is flattened what value to set that axis's scale to for display.
Declaration
public float FlattenAxisDisplayScale { get; set; }
Property Value
Type | Description |
---|---|
Single |
HandleCloseProximity
Distance between handle and hand that will trigger the close proximity effect.
Declaration
public float HandleCloseProximity { get; }
Property Value
Type | Description |
---|---|
Single |
HandleGrabbedMaterial
Material applied to handles while they are a grabbed
Declaration
public Material HandleGrabbedMaterial { get; set; }
Property Value
Type | Description |
---|---|
Material |
HandleMaterial
Material applied to handles when they are not in a grabbed state
Declaration
public Material HandleMaterial { get; set; }
Property Value
Type | Description |
---|---|
Material |
HandleMediumProximity
Distance between handle and hand before proximity scaling will be triggered.
Declaration
public float HandleMediumProximity { get; }
Property Value
Type | Description |
---|---|
Single |
HandlesIgnoreCollider
Add a Collider here if you do not want the handle colliders to interact with another object's collider.
Declaration
public Collider HandlesIgnoreCollider { get; set; }
Property Value
Type | Description |
---|---|
Collider |
HideElementsInInspector
Determines whether to hide GameObjects (i.e handles, links etc) created and managed by this component in the editor
Declaration
public bool HideElementsInInspector { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
MediumGrowRate
Scaling animation velocity from far to medium proximity.
Declaration
public float MediumGrowRate { get; }
Property Value
Type | Description |
---|---|
Single |
MediumScale
A Proximity-enabled Handle scales by this amount when a hand moves into the Medium Proximity range. Default is 1.0, original handle size.
Declaration
public float MediumScale { get; set; }
Property Value
Type | Description |
---|---|
Single |
ProximityEffectActive
Determines whether proximity feature (scaling and material toggling) for bounding box handles is activated
Declaration
public bool ProximityEffectActive { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
RotateHandleColliderPadding
Additional padding to apply to the collider on rotate handle to make handle easier to hit
Declaration
public Vector3 RotateHandleColliderPadding { get; set; }
Property Value
Type | Description |
---|---|
Vector3 |
RotateMidpoints
Returns list of transforms pointing to the rotation handles of the bounding box.
Declaration
public IReadOnlyList<Transform> RotateMidpoints { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<Transform> |
RotationHandlePrefab
Prefab used to display rotation handles in the midpoint of each edge. Aligns the Y axis of the prefab with the pivot axis, and the X and Z axes pointing outward. If not set, spheres will be displayed instead
Declaration
public GameObject RotationHandlePrefab { get; set; }
Property Value
Type | Description |
---|---|
GameObject |
RotationHandlePrefabColliderType
Determines the type of collider that will surround the rotation handle prefab.
Declaration
public BoundingBox.RotationHandlePrefabCollider RotationHandlePrefabColliderType { get; set; }
Property Value
Type | Description |
---|---|
BoundingBox.RotationHandlePrefabCollider |
RotationHandleSize
Radius of the handle geometry of rotation handles
Declaration
public float RotationHandleSize { get; set; }
Property Value
Type | Description |
---|---|
Single |
RotationHandleSlatePrefab
Prefab used to display rotation handles in the midpoint of each edge. Aligns the Y axis of the prefab with the pivot axis, and the X and Z axes pointing outward. If not set, spheres will be displayed instead
Declaration
[Obsolete("This property has been renamed RotationHandlePrefab.")]
public GameObject RotationHandleSlatePrefab { get; set; }
Property Value
Type | Description |
---|---|
GameObject |
ScaleCorners
Returns list of transforms pointing to the scale handles of the bounding box.
Declaration
public IReadOnlyList<Transform> ScaleCorners { get; }
Property Value
Type | Description |
---|---|
IReadOnlyList<Transform> |
ScaleHandleColliderPadding
Additional padding to apply to the collider on scale handle to make handle easier to hit
Declaration
public Vector3 ScaleHandleColliderPadding { get; set; }
Property Value
Type | Description |
---|---|
Vector3 |
ScaleHandlePrefab
Prefab used to display scale handles in corners. If not set, boxes will be displayed instead
Declaration
public GameObject ScaleHandlePrefab { get; set; }
Property Value
Type | Description |
---|---|
GameObject |
ScaleHandleSize
Size of the cube collidable used in scale handles
Declaration
public float ScaleHandleSize { get; set; }
Property Value
Type | Description |
---|---|
Single |
ScaleHandleSlatePrefab
Prefab used to display scale handles in corners for 2D slate. If not set, boxes will be displayed instead
Declaration
public GameObject ScaleHandleSlatePrefab { get; set; }
Property Value
Type | Description |
---|---|
GameObject |
ScaleMaximum
Deprecated: Use MinMaxScaleConstraint component instead. Public property for the scale maximum, in the target's local scale. Set this value with SetScaleLimits.
Declaration
[Obsolete("Use a MinMaxScaleConstraint component instead. ScaleMinimum as it is the authoritative value for max scale")]
public float ScaleMaximum { get; }
Property Value
Type | Description |
---|---|
Single |
ScaleMinimum
Deprecated: Use MinMaxScaleConstraint component instead. Public property for the scale minimum, in the target's local scale. Set this value with SetScaleLimits.
Declaration
[Obsolete("Use a MinMaxScaleConstraint. ScaleMinimum as it is the authoritative value for min scale")]
public float ScaleMinimum { get; }
Property Value
Type | Description |
---|---|
Single |
ShowRotationHandleForX
Check to show rotation handles for the X axis
Declaration
public bool ShowRotationHandleForX { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
ShowRotationHandleForY
Check to show rotation handles for the Y axis
Declaration
public bool ShowRotationHandleForY { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
ShowRotationHandleForZ
Check to show rotation handles for the Z axis
Declaration
public bool ShowRotationHandleForZ { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
ShowScaleHandles
Public property to Set the visibility of the corner cube Scaling handles. This property can be set independent of the Rotate handles.
Declaration
public bool ShowScaleHandles { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
ShowWireFrame
Show a wireframe around the bounding box when checked. Wireframe parameters below have no effect unless this is checked
Declaration
public bool ShowWireFrame { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
Target
The object that the bounding box rig will be modifying.
Declaration
public GameObject Target { get; set; }
Property Value
Type | Description |
---|---|
GameObject |
TargetBounds
The collider reference tracking the bounds utilized by this component during runtime
Declaration
public BoxCollider TargetBounds { get; }
Property Value
Type | Description |
---|---|
BoxCollider |
WireframeEdgeRadius
Radius for wireframe edges
Declaration
public float WireframeEdgeRadius { get; set; }
Property Value
Type | Description |
---|---|
Single |
WireframeMaterial
Material used for wireframe display
Declaration
public Material WireframeMaterial { get; set; }
Property Value
Type | Description |
---|---|
Material |
WireframeShape
Shape used for wireframe display
Declaration
public BoundingBox.WireframeType WireframeShape { get; set; }
Property Value
Type | Description |
---|---|
BoundingBox.WireframeType |
Methods
CreateRig()
Destroys and re-creates the rig around the bounding box
Declaration
public void CreateRig()
HighlightWires()
Allows to manually enable wire (edge) highlighting (edges) of the bounding box. This is useful if connected to the Manipulation events of a ObjectManipulator when used in conjunction with this MonoBehavior.
Declaration
public void HighlightWires()
OnSourceDetected(SourceStateEventData)
Declaration
public void OnSourceDetected(SourceStateEventData eventData)
Parameters
Type | Name | Description |
---|---|---|
SourceStateEventData | eventData |
OnSourceLost(SourceStateEventData)
Declaration
public void OnSourceLost(SourceStateEventData eventData)
Parameters
Type | Name | Description |
---|---|---|
SourceStateEventData | eventData |
SetScaleLimits(Single, Single, Boolean)
Sets the minimum/maximum scale for the bounding box at runtime.
Declaration
[Obsolete("Use a MinMaxScaleConstraint script rather than setting min/max scale on BoundingBox directly")]
public void SetScaleLimits(float min, float max, bool relativeToInitialState = true)
Parameters
Type | Name | Description |
---|---|---|
Single | min | Minimum scale |
Single | max | Maximum scale |
Boolean | relativeToInitialState | If true the values will be multiplied by scale of target at startup. If false they will be in absolute local scale. |
UnhighlightWires()
Declaration
public void UnhighlightWires()