Skip to main content

Module fields

Module fields 

Source
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§

AtlasKey
A pair<GUID, SInt64>: m_RenderDataKey, and a key of an atlas’s m_RenderDataMap, equal as UnityPy’s tuples of a GUID and an int are, field by field.
Pptr
A PPtr’s two ids.
RenderData
A render data’s texture, alpha texture, rectangle and settings: a SpriteRenderData (m_RD) or an atlas’s SpriteAtlasData (:83-86).
SpriteFields
What render() and select_render_data read of a Sprite, borrowing from its Parsed tree.

Functions§

atlas_render_data
The SpriteAtlasData of atlas’s m_RenderDataMap whose key is key (next(value for key, value in ...), :78): the first such entry, or SpriteError::NoAtlasData where none is. A Sprite with no m_RenderDataKey compares None with every key, which matches none. Each entry counts one unit of meter’s decode work before it is read, and each field lookup its own (module docs): the atlas’s fields walked to m_RenderDataMap, each key’s to its words.
select_render_data
The render data get_image_from_sprite renders sprite from (module docs, :63-81): deref resolves m_SpriteAtlas where it is set (None, no object, is SpriteError::AtlasUnresolved); else, where the Sprite has an atlas tag, file_atlases lists the file’s SpriteAtlas objects 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 own m_RD. Each atlas compared counts one unit of meter’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_data counts its own (module docs).

Type Aliases§

Guid
A GUID’s four words, data[0] to data[3], by name.