Choose the cut primitive#
| Request | Geometry behavior |
|---|---|
SliceLine / SliceLineDetailed | An infinite straight line. |
SliceSegment / SliceSegmentDetailed | A finite segment that must cross both sides of a piece. |
SlicePath / SlicePathDetailed | An ordered sequence of straight segments, rather than a curved boolean cut. |
The simple methods provide status/split counts. Use a Detailed variant when gameplay needs fragment metadata, positions or failure information.
All endpoints must be in the intended world-space positions. A finite segment that starts or ends inside a piece may not cross both boundaries; use suitable outside endpoints, or use a line when an infinite cut matches your design.
Inspect a detailed result#
The guide supplies this contextual example. target, start and end are references/positions from your own gameplay component; this is not a complete standalone script.
RuntimeSliceResult result = target.SliceSegmentDetailed(start, end, force: 2f);
if (!result.Success)
{
Debug.Log(result.Failure + ": " + result.Reason);
return;
}
foreach (RuntimeFragmentInfo f in result.Fragments)
{
if (f.OriginalRatio < 0.25f) { /* game-specific rule */ }
Debug.Log($"{f.FragmentId} parent={f.ParentFragmentId}, generation={f.Generation}");
}Result and fragment fields#
| Type | Exposed information described in the guide |
|---|---|
RuntimeSliceResult | Success, SourceObject, OriginalSourceId, cut positions/direction, LineStart, LineEnd, IsFiniteSegment, Failure, Reason and new Fragments. |
RuntimeFragmentInfo | Fragment, IDs, OriginalRatio, ParentRatio, Area, Bounds and Generation. |
LastRuntimeSliceResult | Inspect the last result when diagnosing a rejected request. |
TryGetRuntimeFragment / TryGetParent | Resolve active fragments and current-cycle ancestry. |
Detailed cut positions include world CutPosition, source-local LocalPosition and NormalizedSpritePosition. Read ratios and ancestry before treating these values as gameplay scores.
Respect fragment lifetime#
Handles refer to active pooled pieces. They become invalid when those pieces retire, and reassembly clears their prior ancestry. Subscribe to slice and reassembly events for lifecycle-aware gameplay and discard stale references.
The supplied PDF gives API fragments rather than complete class/namespace declarations for these examples. Consult the package's own Documentation/Runtime-Slicing.md for project-level integration details.