Is it possible to get sprite of the attachment in code to use it with other Game Objects? Thank you!
  • Posts: 3


You can access the Texture and the UV coordinate region of an Attachment, but you will not get an object of type Sprite directly. A Sprite in Unity is a special structure which is created when Textures are set to mode Sprite, and it holds reference to a Texture and additional information such as the image region, rotation and the like (since they are packed to an Atlas in the background). What you can do is create the Sprite yourself from the retrieved Attachment Texture and Region parameters:

To access Texture and the UV information of the Attachment you can call attachment.GetRegion() to retrieve the AtlasRegion object which holds all information about the atlas texture region.
User avatar

  • Posts: 2076

Return to Unity