Slicer Controller
The Slicer Controller
is the main script for controlling the slicing of Game Objects.
It co-ordinates any Slicer Components that are on the same Game Object to it.
It also co-ordinates any Slice Modifiers that are a descendent of the Slicer Controller
.
A descendent Slicer Ignore component or Slicer Controller
will stop further processing of that branch of Game Object descendants.
Properties
Property | Function |
---|---|
Size | Adjusts the final dimensions of the sliced item. |
Slices | Adjusts where the slices should occur. Ranging from 0 (the center of the object), to 1 being the furthest extents of the object. |
Enable Edit Mode OR Disable Edit Mode | (Edit Mode Only) When clicked, Edit Mode will be toggled on/off. |
Refresh Slice | (Play Mode Only) When clicked, the controller will refresh the slices that are being controlled by this Slicer Controller . |
Details
A Slicer Controller
works in tandem with any Slicer Components
that are on the same Game Object to it.
The Slicer Controller
scans its descendants to find Game Objects that have items that are of interest to any Slicer Components
.
The Slicer Controller
will manage which Game Objects should be sliced, while the Slicer Components
determines if those Game Objects have any items that it can slice.
Such as a Mesh Slicer Component
knows it can slice a mesh.
It will also manage any Slice Modifiers
it finds while scanning the Slicer Controllers
descendants.
When scanning through the hierarchy if it encounters a Slicer Ignore
it will process any Slice Modifiers
on that Game Object and will stop processing any further down that branch of descendants.
Similarly if it encounters another Slicer Controller
it will stop processing any further down that branch of descendants.
Hotkeys
A Slicer Controller
has a few keyboard shortcuts to quickly performs tasks. These hotkeys are only available in the Unity Editor.
Hotkey | Name | Description |
---|---|---|
Alt+S | Toggle Slicer Controller Mode* | Outside of Play Mode the Slicer Controllers Edit Mode is toggled on and off. |
Ctrl+Alt+S | Toggle All Slicer Controllers Mode | Outside of Play Mode all of the Slicer Controllers Edit Mode is toggled on and off. |
Alt+R | Refresh Slicer Controller* | Re-slices the items that are controlled by this Slicer Controller . |
Ctrl+Alt+R | Refresh All Slicer Controllers | Re-slices the items that are controlled by all Slicer Controllers . |
Alt+/ | Swap Scale With Size* | Swaps the Size property of the selected Slicer Controllers with its Game Objects Scale property.Useful for when you have many Game Objects with varied scales and you want to convert them to be sliced. This utility is also available from the Slicer Controllers context menu (Right click the top bar of the Slicer Controller). |
* Works with multiple selected objects.
Slicing vs Scaling
Scaling a model will always stretch its details, generally this is not a desired outcome.
When slicing a model we can take the parts of the model we do not want to distort and simply move them. The remaining part of the model is stretched to fit the remaining space left by the moved parts.
In the example below the slicer is set to slice the very center of the rug. This results in all of the vertices of the rug being moved outwards to fit the size of the slicer.
Edit Mode Button
This button enables and disables Edit Mode. In Edit Mode you can safely change the properties of components that is normally edited when slicing. It also enables Gizmos in the scene view to help with visualizing how the object will be sliced.
Note
It is recommended that you have the parent Slicer Controller in Edit Mode
when you are making changes to how an object is being sliced.
In most cases it is ok to make changes outside of edit mode, but if you are having issues with slices staying set, try making the adjustments in edit mode instead.
Size Property
The Size
property determines the final dimensions of the sliced Game Object. It will scale up the original bounds of the Game Object using this property.
Setting the vector to (x: 2, y: 1.5, z: 0.5) will double the x dimension, add an additional 50% of the size to the y dimension and will halve the z dimension.
In edit mode the size
property is represented by the yellow outline.
Slices Property
The Slices
property determines where the slices happen for each dimension. Ranging from 0 (the center of the object), to 1 being the furthest extents of the object.
In the case of Mesh getting sliced, any vertices that fall within the center of the Mesh and the provided values will be stretched (scaled) by the value of the Size property. Any vertices that are greater than the provided value will be moved (translated) linearly.
In edit mode the slices
property is represented by the red outlines.
Finalizing Slices
A Slicer Controller can be 'Finalized'. When a Slicer Controller
is finalized it will destroy all of the slicing components attached to the Game Object while leaving the sliced meshes in place.
A Slicer Controller
can be Finalized through one of the following methods
- Exporting a Sliced Mesh with the
Finalize Slices
option checked. - Calling the SlicerController.FinalizeSlicing() method at runtime.
- Right clicking the Title Bar of the
Slicer Controller
then Finalize Slicing. Note: As the sliced mesh is not exported, the mesh might not be retained by Unity. For this reason it is only recommended that this option is used when the editor is in playmode.