public record class SpriteA named region of a texture, and everything needed to draw it at the size it was drawn at.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Texels in, world units out. Everything authored about a sprite is in the texture's own pixels — where the region is, how wide its nine-slice borders are, where its pivot sits — because that is what an artist sees and what an importer reads out of a sheet. PixelsPerUnit is the one number that turns all of it into the units a scene is measured in, and it is per sprite rather than per project so that a background painted at a quarter of the resolution is a different sprite and not a different scene.
⚠ No texture handle, and that is not an omission. What binds the atlas is the material — the same MaterialRenderFeature a mesh goes through — so a sprite that named a texture view would be naming it twice and would be a graphics type in a record that is otherwise pure data. What it does need is TextureSize, because that is the denominator that turns a region in texels into the UVs a vertex carries, and no amount of material binding supplies it.
⚠ TextureSize is on the sprite even though the sheet has it too. A sprite reaches SpriteRenderFeature on its own — one sprite on one object, most of the time — and a sprite that could not answer its own UVs without the sheet it was cut from would make every consumer carry the pair. The duplication is a value copied into a value; the alternative is a back-reference, which turns two records into a graph.
Fields and properties (13)
public const float DefaultPixelsPerUnitHow many texels make one world unit, when nobody says otherwise.
public string NameWhat it is called, which is how a sheet is looked up.
public Rectangle RegionWhich part of the texture it is, in texels from the top-left.
public Int2 TextureSizeHow big the whole texture is, in texels.
public Vector2 PivotWhere the sprite's origin sits inside its region, as a fraction from the bottom-left.
public NineSlice BorderHow far the nine-slice corners reach in, in texels. Empty for a plain sprite.
public float PixelsPerUnitHow many texels make one world unit.
public Vector2 SizeHow big the sprite is in world units at its authored size.
public Rectangle UvWhere the region is in UVs, which is what a vertex carries.
public NineSlice UvBorderThe nine-slice border in UVs, which is how Uv is cut.
public NineSlice UnitBorderThe nine-slice border in world units, which is how Size is cut.
public bool IsSlicedWhether this sprite is drawn as nine cells rather than one quad.
public bool IsDrawableWhether there is anything to draw at all.
Used by (15)
- SpriteAnimationVixen.Rendering
- SpriteGeometryVixen.Rendering
- SpriteRenderFeatureVixen.Rendering
- SpriteRenderFeatureTestsVixen.Rendering.Tests
- SpriteSheetVixen.Rendering
- SpriteTestsVixen.Rendering.Tests
- TypeRegistrationVixen.Rendering
- Vixen_Rendering_Sprites_SpriteSerializerVixen.Rendering
- Vixen_Rendering_Sprites_SpriteSheetSerializerVixen.Rendering
- SpriteRectVixen.Editor.Assets
- SpriteSlicerTestsVixen.Editor.Assets.Tests
- TextureImportEditsVixen.Editor.AssetEditors
- TextureImportSettingsVixen.Editor.Assets
- TextureImporterVixen.Editor.Assets
- TextureImporterTestsVixen.Editor.Assets.Tests