Expand description
What get_image_from_sprite reads of a Sprite and of its atlas
(export/SpriteHelper.py:63-88), from a Parsed object: the
Sprite’s m_PixelsToUnits, m_RD, m_SpriteAtlas, m_AtlasTags and
m_RenderDataKey, and an atlas’s m_RenderDataMap entry for the
sprite’s key.
select_render_data settles which render data a sprite renders
from, as get_image_from_sprite settles it (:63-81): a non-null
m_SpriteAtlas (Pptr::is_set) names the atlas; else, where
m_AtlasTags is not empty, the file’s first SpriteAtlas whose name is
its first tag (a SpriteAtlas of another name before it is skipped, and
none found is no atlas); with an atlas, the entry of its
m_RenderDataMap whose key equals m_RenderDataKey
(atlas_render_data; none is StopIteration,
SpriteError::NoAtlasData); with none, the Sprite’s own m_RD
(SpriteFields::rd). The caller resolves the pointer and lists the
file’s atlases, since both are the file’s. The mesh is always the
Sprite’s own m_RD’s.
A key’s GUID is UnityPy’s GUID class, whose equality compares
data_0_ to data_3_ in that order (classes/generated.py), so its
words are read by name (data[0] to data[3]), whatever order the
typetree gives them.
Each step of every loop here counts decode work on the caller’s meter
before it runs, so that a file of many atlases, an atlas of many entries
or fields, or names of many bytes, scanned for each of many sprites, is
bounded by the caller’s allowance: each field a lookup walks (field,
the Parsed::field scan, metered), each atlas compared, each map
entry, and each tag checked, counts one unit, and each name or tag
comparison as many more as the bytes it may read (compared).
Structs§
- Atlas
Key - A
pair<GUID, SInt64>:m_RenderDataKey, and a key of an atlas’sm_RenderDataMap, equal as UnityPy’s tuples of aGUIDand anintare, field by field. - Pptr
- A
PPtr’s two ids. - Render
Data - A render data’s texture, alpha texture, rectangle and settings: a
SpriteRenderData(m_RD) or an atlas’sSpriteAtlasData(:83-86). - Sprite
Fields - What
render()andselect_render_dataread of a Sprite, borrowing from itsParsedtree.
Functions§
- atlas_
render_ data - The
SpriteAtlasDataofatlas’sm_RenderDataMapwhose key iskey(next(value for key, value in ...),:78): the first such entry, orSpriteError::NoAtlasDatawhere none is. A Sprite with nom_RenderDataKeycomparesNonewith every key, which matches none. Each entry counts one unit ofmeter’s decode work before it is read, and each field lookup its own (module docs): the atlas’s fields walked tom_RenderDataMap, each key’s to its words. - select_
render_ data - The render data
get_image_from_spriterendersspritefrom (module docs,:63-81):derefresolvesm_SpriteAtlaswhere it is set (None, no object, isSpriteError::AtlasUnresolved); else, where the Sprite has an atlas tag,file_atlaseslists the file’sSpriteAtlasobjects in its order, each as its name (peek_name) and a parse of it, which is called only for the first whose name is the tag; else, or with no atlas found, the Sprite’s ownm_RD. Each atlas compared counts one unit ofmeter’s decode work, and as many more as the bytes its name’s comparison with the tag may read (compared), before it is compared;atlas_render_datacounts its own (module docs).
Type Aliases§
- Guid
- A
GUID’s four words,data[0]todata[3], by name.