public sealed class SpriteSheetViewA texture with the sprites cut out of it drawn on top, and the controls that cut them.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
The panel a sprite sheet is sliced in. Three ways to cut — a grid by cell size, a grid by cell count, and one sprite per island of opaque texels — then the rects as boxes over the picture, a list beside it, and the selected rect's numbers underneath. What it does not have is a mode of its own: slicing writes rects onto the texture's own import settings, so this is a second view over TextureImportDocument rather than a second document over the same file. Two documents over one .meta would be two undo histories over one set of bytes, and whichever saved last would win.
⚠ It shows the picture and does not draw it, exactly as TextureImportView does and for the same reason: nothing in this assembly has a graphics device, so a texture reaches the interface as a number a UiRenderer handed out for one it uploaded. The view decodes the file — CPU work, and what the slicer needs anyway — and the application puts the number in Preview.
⚠ Every rect on the overlay is positioned inline in texels times Zoom, not by layout. A stylesheet cannot express "this box is at texel 96 of that picture", and computing it here rather than reading it back out of the layout is what lets the overlay be asserted in a test without a frame having been drawn.
⚠ Slicing is a suggestion. What it produces goes into the document as rects an author then drags, renames and deletes — the sidecar records the answer rather than the question. SpriteSlicer's own remarks say why: an automatic slice depends on the pixels, so a re-export with one frame nudged would renumber the sheet and quietly repoint every reference into it.
Fields and properties (36)
protected override string TagNameThe element name this type answers to when a caller does not choose one.
protected override bool AcceptsFocusWhether the focus can rest on this kind of control at all.
public Image PreviewWhere the texture is drawn once something has uploaded it.
public UiElement CanvasThe picture and the boxes over it, sized to the texture times Zoom.
public IReadOnlyList<UiElement> RectsThe boxes, one per sprite, in the document's order.
public UiElement ListThe sprite names, one row each.
public UiElement FieldsThe selected sprite's numbers.
public Select MethodHow the texture is cut.
public NumericInput CellWidthThe cell's width, or the column count — whichever the method reads.
public NumericInput CellHeightThe cell's height, or the row count.
public NumericInput GridOffsetXWhere the grid starts, horizontally.
public NumericInput GridOffsetYWhere the grid starts, vertically.
public NumericInput PaddingXThe gap between cells, horizontally.
public NumericInput PaddingYThe gap between cells, vertically.
public ToggleButton TrimToggleWhether each rect is shrunk to what is drawn inside it.
public ToggleButton KeepEmptyToggleWhether a grid keeps cells with nothing in them.
public Button SliceButtonCuts the texture with the options as they stand.
public Button ClearButtonThrows every sprite away.
public Button AddButtonAdds one sprite covering the whole texture, for a sheet cut by hand.
public Button RemoveButtonRemoves the selected sprite.
public Alert UnavailableShown when there are no pixels to slice.
public TextureData? SourceThe decoded source, or if nothing could decode it.
public int SelectedWhich sprite is selected, or -1 for none.
public float ZoomHow many screen pixels one texel takes.
public SpriteSliceOptions OptionsThe options the toolbar is asking for.
public TextBox NameThe selected sprite's name.
public NumericInput RectXIts left edge, in texels.
public NumericInput RectYIts top edge.
public NumericInput RectWidthIts width.
public NumericInput RectHeightIts height.
public NumericInput PivotXIts pivot, horizontally.
public NumericInput PivotYIts pivot, vertically.
public NumericInput BorderLeftIts nine-slice border, from the left.
public NumericInput BorderTopFrom the top.
public NumericInput BorderRightFrom the right.
public NumericInput BorderBottomFrom the bottom.
Events (1)
public Action<SpriteSheetView>? SelectionChangedRaised when a different sprite is selected.
Methods (6)
protected override void OnCreated()Builds whatever this element is made of, once, as it joins a document.
public void Show(TextureImportDocument texture)Shows a texture's sprites.
public int Slice()Cuts the texture with the options the toolbar is asking for.
public void Select(int index)Selects a sprite, or nothing.
public void FitTo(float width, float height)Sets the zoom so that the whole texture fits inside a box.
public void Restate()Rebuilds the overlay, the list and the fields from the document as it stands.
Used by (2)
- SpriteViewTestsVixen.Editor.AssetEditors.Tests
- TextureImportViewVixen.Editor.AssetEditors