Struct Sprite2D | Package Manager UI website
docs.unity3d.com
    Show / Hide Table of Contents

    Struct Sprite2D

    A component describing a sprite as a sub-region of an image. Specifies the source Image2D atlas and the region to use.

    Namespace: Unity.Tiny.Core2D
    Syntax
    public struct Sprite2D : IComponentData

    Fields

    image

    The Entity on which to look for a Image2D component to use as the source image. If null, the Image2D is looked for on the same entity as the Sprite2D.

    Declaration
    [EntityWithComponents(new Type[]{typeof(Image2D)})]
    public Entity image
    Field Value
    Type Description
    Entity

    imageRegion

    The region of the source image to use as the sprite.

    Declaration
    public Rect imageRegion
    Field Value
    Type Description
    Rect
    Remarks

    The image is treated as a unit rectangle; thus this rectangle should use values in the range of 0..1. For example, to use the bottom left portion of the image, the rectangle should go from (0, 0) to (0.5, 0.5)

    pivot

    The point in the sprite that is the sprite's center. Relative to the bottom-left corner of the sprite, in unit rectangle coordinates.

    Declaration
    public float2 pivot
    Field Value
    Type Description
    float2

    pixelsToWorldUnits

    Conversion ratio of sprite image pixels to world units, e.g.: The default value is 1.

    Declaration
    public float pixelsToWorldUnits
    Field Value
    Type Description
    System.Single
    Remarks

    This should not be used for scaling sprites.

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023