Skip to main content

Module objmode

Module objmode 

Source
Expand description

An object-mode view: a dict-mode value the core read, viewed as the objects UnityPy’s object mode builds from it.

UnityPy hands MeshHandler an object (obj.read()), which UnityPyBoost builds class by class (parse_class, UnityPyBoost/TypeTreeHelper.cpp:458-583; PARITY.md section 9.2): each class node’s fields are its children’s clean names (clean_name, :28-65), and the class named by the node’s type is called with them. A class whose required field is missing, or a slotted class (every class here but Mesh and Sprite, PARITY.md section 9.2.1) given a field it lacks, falls back to an UnknownObject holding the fields as attributes. So a field the handler reads is the value of the last child of that clean name, and a missing one is the field’s default (None) on a class that was built and an AttributeError on an UnknownObject (Obj::get).

The core’s value is a dict keyed by each child’s raw name (the first child of a name holding its last value), so Obj finds the child by clean name in the node list and its value under its raw name, never copying.

What is refused (ViewError::Malformed, Tier U): a node whose type is not the class its field’s typetree names (object mode would look up another class); a field whose value is not of a type some version’s typetree gives it (an int field holding a string, a class field holding an int), or an integer outside the widest type any version gives it (ChannelInfo’s UInt8s, StreamInfo’s UInt32s). UnityPy’s arithmetic on such values is uncharacterised, and the bounds keep every loop the handler runs proportional to its input. A message names a node’s type by at most NAME_BYTES bytes of it ([type_name]), so a refusal allocates no more for a long one.

Work. Each scan of a node’s children counts one unit of decode work for every name the scan may compare, counted before it, on the meter Obj carries: Obj::get the children and the dict’s entries, and the test of whether object mode builds a class ([builds]) each child against each field it looks for. So reading a class of N fields is work in N, wherever the handler reads it.

Structs§

Class
A class’s attrs fields (classes/generated.py), and whether object mode builds it as an UnknownObject when given a field it lacks (PARITY.md section 9.2.1: a non-empty __slots__).
List
A list of objects of one class (one element node, so one answer to whether object mode builds them).
Obj
One object, as object mode builds it from a class node (module docs), with the meter its reads count their work on.

Enums§

Ints
A list of integers: a primitive run, or a list or tuple of ints.
ViewError
A failure reading an object-mode attribute.

Constants§

BONE_WEIGHTS
A skin element: BoneWeights4 or BoneInfluence, the same fields (classes/generated.py:6956-6976); m_Skin is a list of either.
CHANNEL_INFO
ChannelInfo (classes/generated.py:7213-7217).
COMPRESSED_MESH
CompressedMesh (classes/generated.py:7488-7501).
MESH
Mesh (classes/generated.py:4605-4642), whose __slots__ is ().
MESH_6000
Mesh from Unity 6000 (Tier C, PARITY.md section 19.1): UnityPy git 417d595’s fields (HEAD classes/generated.py:4813-4852, unchanged at master), from a newer TPK: m_MeshUsageFlags, which Unity 6000.6 no longer writes, has the default None, and the two m_PreBake* flags are new. 1.25.2 requires it, so builds an UnknownObject.
NAME_BYTES
The most bytes of a node’s type a ViewError::Malformed message holds (module docs).
PACKED_BIT_VECTOR
PackedBitVector (classes/generated.py:9160-9165).
SPRITE
Sprite (classes/generated.py:4867-4882), whose __slots__ is ().
SPRITE_RENDER_DATA
SpriteRenderData (classes/generated.py:10903-10919).
STREAMING_INFO
StreamingInfo (classes/generated.py:11067-11070).
STREAM_INFO
StreamInfo (classes/generated.py:11043-11049).
SUB_MESH
SubMesh (classes/generated.py:11098-11107).
VERTEX_DATA
VertexData (classes/generated.py:11800-11809).