Vixen
02b45cc4
csharp
public record class SpriteRect

One sprite cut out of a texture, as the sidecar records it.

No guide page documents this yet — the page shows what the code says about itself.

Remarks

Primitives rather than the engine's own structs, and that is the sidecar talking. A Rectangle is four readonly fields with no setter and a NineSlice is a positional record; the YAML binder builds a settings object by writing its members, so either of them here would round-trip as a key the reader could not fill in. Written out flat, a sprite in a .meta is eleven scalars a human can read and edit, which is what a sidecar is for. Region, Pivot and Border put the engine's shapes back on top, and are computed rather than stored so nothing has two answers.

⚠ Texels of the source image, not of the shipped texture. A texture over MaxSize ships halved, and the rects are not rescaled to match — they do not need to be. A UV is a region divided by the texture's size and both halve together, so the sprite samples the same picture either way, and its world size stays what the artist drew at the resolution they drew it. Rescaling would round every rect to a texel grid it was not authored on, once per halving.

Fields and properties (15)

  • public string Name

    What the sprite is called. This is what a reference to it resolves by.

  • public int X

    Its left edge, in texels from the left.

  • public int Y

    Its top edge, in texels from the top.

  • public int Width

    How wide it is, in texels.

  • public int Height

    How tall it is, in texels.

  • public float PivotX

    Where its origin sits, as a fraction from the bottom-left.

  • public float PivotY

    The same, vertically.

  • public int BorderLeft

    How far the nine-slice's left border reaches in, in texels.

  • public int BorderTop

    The same, from the top.

  • public int BorderRight

    The same, from the right.

  • public int BorderBottom

    The same, from the bottom.

  • public Rectangle Region

    Where it is, as the shape the rest of the engine uses.

  • public Vector2 Pivot

    Its pivot, as the shape the rest of the engine uses.

  • public NineSlice Border

    Its border, as the shape the rest of the engine uses.

  • public bool IsEmpty

    Whether it encloses anything.

Methods (2)

  • public static SpriteRect From(string name, Rectangle region, Vector2? pivot = null, NineSlice border = default(NineSlice))

    Builds a rect from the shapes the rest of the engine uses.

  • public Sprite ToSprite(Int2 textureSize, float pixelsPerUnit)

    Turns this into the sprite the runtime draws.

Used by (13)

  • SpriteDocumentTestsVixen.Editor.AssetEditors.Tests
  • SpriteEditCommandVixen.Editor.AssetEditors
  • SpriteSheetViewVixen.Editor.AssetEditors
  • SpriteSlicerVixen.Editor.Assets
  • SpriteSlicerTestsVixen.Editor.Assets.Tests
  • SpriteViewTestsVixen.Editor.AssetEditors.Tests
  • TextureImportDocumentVixen.Editor.AssetEditors
  • TextureImportEditsVixen.Editor.AssetEditors
  • TextureImportSettingsVixen.Editor.Assets
  • TextureImporterVixen.Editor.Assets
  • TextureImporterTestsVixen.Editor.Assets.Tests
  • TypeRegistrationVixen.Editor.Assets
  • Vixen_Editor_AssetEditors_Importing_TextureImportEditsSerializerVixen.Editor.AssetEditors