Search Unity

Question Retrieving sprites from sprite asset

Discussion in 'UGUI & TextMesh Pro' started by ihgyug, Aug 27, 2020.

  1. ihgyug

    ihgyug

    Joined:
    Aug 5, 2017
    Posts:
    194
    Hi,

    I am trying to get sprites from a specific sprite asset so that, from a single sprite asset, I can both retrieve the sprites and use it for text, using a single name or index (without having to keep a reference to both a sprite and the name/index, avoiding possible mismatch in case of updates).

    Problem is, when I reference the sprite asset, the "spriteInfoList" is empty :eek:

    Am I doing it the wrong way?

    Thanks.
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    SpriteInfoList is deprecated as the structure of sprite assets now mirror that of font asset where we now have a table of sprite characters and sprite glyphs.

    The sprite characters contain the name of the sprite, unicode and an index of a sprite glyph.

    The sprite glyph is the visual representation of the sprite and defines the coordinates of that sprite in the atlas texture along with its metrics.

    Multiple sprite characters can reference the same sprite glyph.

    The above is how font assets and fonts are structured where a character has a unicode value and references a glyph.
     
    ihgyug likes this.