Provides snap point functionality through composition pattern. More...
Classes | |
| class | OnIsSnappedEvent |
| class | OnIsUnsnappedEvent |
Public Member Functions | |
| void | CheckSnap () |
| Checks all child snap points for connections. | |
| void | Update () |
| void | Connect (SnapPoint ownSnapPoint, SnapPoint snapPointMate, ISnapable mateObject, bool ismoved) |
| void | Align (SnapPoint ownsnappoint, SnapPoint matesnappoint, Quaternion additonalrotation) |
| void | Disconnect (SnapPoint snapPoint, SnapPoint snapPointMate, ISnapable Mateobj, bool ismoved) |
| void | Modify () |
| Called when properties are modified in the editor. | |
| void | AttachTo (SnapPoint attachto) |
| Attaches this object to a snap point. | |
Public Attributes | |
| bool | AlignXOnSnap |
| Align the object x-axis to the snap point. | |
| OnIsSnappedEvent | OnIsSnapped |
| OnIsUnsnappedEvent | OnIsUnsnapped |
Properties | |
| OnSnappedEvent | OnSnapped [get, set] |
Properties inherited from realvirtual.ISnapable | |
Detailed Description
Provides snap point functionality through composition pattern.
This component implements ISnapable and handles all snap point logic automatically. Components that need snap functionality can simply add [RequireComponent(typeof(SnapControl))] instead of implementing ISnapable themselves. This eliminates boilerplate code and ensures consistent snap behavior across all components.
Key Features:
- Automatic snap point management for child SnapPoint components
- Movement detection triggers snap checks automatically
- Optional X-axis alignment via AlignXOnSnap property
- Unity events for snap/unsnap notifications
- Works in both edit mode and play mode
Usage Example: [RequireComponent(typeof(SnapControl))] public class MyComponent : MonoBehaviour { // No ISnapable implementation needed - SnapControl handles it }
For detailed documentation see: https://doc.realvirtual.io/components-and-scripts/snap-points
Member Function Documentation
◆ AttachTo()
| void realvirtual.SnapControl.AttachTo | ( | SnapPoint | attachto | ) |
Attaches this object to a snap point.
IMPLEMENTS ISnapable::AttachTo
Implements realvirtual.ISnapable.
◆ CheckSnap()
| void realvirtual.SnapControl.CheckSnap | ( | ) |
Checks all child snap points for connections.
IMPLEMENTS ISnapable::CheckSnap
Implements realvirtual.ISnapable.
◆ Connect()
| void realvirtual.SnapControl.Connect | ( | SnapPoint | ownSnapPoint, |
| SnapPoint | snapPointMate, | ||
| ISnapable | mateObject, | ||
| bool | ismoved | ||
| ) |
Implements realvirtual.ISnapable.
◆ Disconnect()
| void realvirtual.SnapControl.Disconnect | ( | SnapPoint | snapPoint, |
| SnapPoint | snapPointMate, | ||
| ISnapable | Mateobj, | ||
| bool | ismoved | ||
| ) |
Implements realvirtual.ISnapable.
◆ Modify()
| void realvirtual.SnapControl.Modify | ( | ) |
Called when properties are modified in the editor.
IMPLEMENTS ISnapable::Modify
Implements realvirtual.ISnapable.
Member Data Documentation
◆ AlignXOnSnap
| bool realvirtual.SnapControl.AlignXOnSnap |
Align the object x-axis to the snap point.
Property Documentation
◆ OnSnapped
|
getset |
Implements realvirtual.ISnapable.
Properties inherited from