2023.1.116.1 Snapping
Overview
Snapping allows the user to quickly position GameObjects in specific ways relative to other GameObjects by dragging them close to each other. For GameObjects to be able to snap together, the user has to create SnappableObjects for each GameObject, describing how they should snap to other GameObjects.
There are several different SnappableObject that describe how GameObjects should snap with each other.
Basic Snappable Objects
There are three basic Snappable Objects. Each of these have their own set of rule on how to snap to other SnappableObjects. Each of these SnappableObject only handle positioning of a GameObject during snapping.
These three SnappableObject are able to snap with each other following this table:
Advanced Snappable Objects
There are currently three Advanced Snappable Objects. Aside from handling positioning of a GameObject, these also have extra rules and/or actions to them during snapping.
Where to find
You can find all of these Snappable Objects in the “Add Component” menu.
Feature Layout
All Snappable Objects have the following basic settings.
Field |
|
I/O | The “direction of flow” of the SnappableObject. SnappableObjects can be set to one of the following three I/O’s:
Depending on the combination of I/O’s between SnappableObjects, they can or cannot snap together. |
Directional | Whether this SnappableObject enforces a certain direction onto SnappableObjects that with it. |
Direction | The forward direction of the SnappableObject that is applied when |
Connected Snappable Objects | A list of all Snappable Objects that the Snappable Object currently is snapped to. |
How to use
Have a GameObject you want to be able to snap to other GameObjects.
Create Snappable Objects for it as required. Make sure to have these parented under the GameObject.
Drag the GameObject closer towards other GameObject with Snappable Objects and snapping will automatically be enabled. A thether will be drawn indicating which Snappable Object will snap together upon releasing the mouse button.
Enable/Disable Snapping
Snapping can be disabled from the Scene View.
In the top left corner of the Scene View you can find the “Enable Snapping” button. By default, this will be enabled. Clicking this button once will disable Snapping for all Snappable Objects. Clicking it again will re-enable Snapping. Holding Alt
on the keyboard will temporarily disable Snapping.
Snap Conditions
Snappable Objects of the SnappablePoint type will have icons indicating whether they are currently snapped, unsnapped, or whether there is currently something wrong with its setup.
The icons in the image below provide with some information about the SnappablePoint.
From left to right:
A “blank” dot means that this SnappablePoint is correctly setup and unsnapped.
A dot with a Check-mark means that this SnappablePoint is correctly setup and snapped to another Snappable Object.
A dot with an exclamation mark means that there is currently something wrong with the setup of the SnappablePoint. This can happen both when snapped or unsnapped.
Secondary Snapping
Secondary snapping allows Snappable Object that “happen to align” as a result of another snap, to also snap together. The snapping system uses a set margin to both position and angle to determine whether a given Snappable Object applies for Secondary Snapping. Settings for both can be found in the Snapping Settings window.
Here are a few examples in which case Secondary Snapping can be very useful:
Snapping a Line to multiple Points
Snapping multiple Snappable Objects under a single parent
Snapping Settings
The Snapping Settings window can be accessed through the context menu of any Snappable Object. This will open a separate window in which you can set various settings.
Fields |
|
---|---|
Distance Factor | The relative maximum length of the tether that is drawn during snapping in the editor. |
Max Distance | The maximum allowed distance between points in meters in order to apply for Secondary Snapping. |
Max Angle | The maximum allowed angle between points in degrees in order to apply for Secondary Snapping. |
Reset Default | Clicking this button will reset all these settings to their default values. |
Prespective Documentation