There is another way to set sprite in unity 2023 with the introduction of Scriptable Objects for Sprites API. This way you can extract SDFSpriteMetadataAsset
directly from sprite.
SDF generation produces some data that need to be used by SDFImage
Sprite
SDFSpriteVector4
BorderOffsetSDFSpriteMetadataAsset
All this data is stored in generated SDFSpriteMetadataAsset
's, and it unity 2023 its possible to add reference to this asset to sprite directly.
In editor you can see that particular sprite has SDFSpriteMetadataAsset
that holds all metadata. This asset is hidden in editor for regular pipeline but visible in decoupled.
Metadata asset can be selected with context menu.
Meta asset associated with sprite
Sample script is using all the functions from sections mentioned below