pub struct Player {
pub dir: PathBuf,
pub files: BTreeMap<String, SerializedFile>,
pub folders: BTreeMap<String, PathBuf>,
pub bundles: Vec<Arc<Bundle>>,
/* private fields */
}Expand description
A Unity player’s data folder, read: every SerializedFile in it (and in its Resources folder), the serialized
files of the bundles it was opened with (Player::open_with_bundles), and the type tree package that decodes
their objects. Objects are named by ObjRef and decoded on demand.
Fields§
§dir: PathBufThe data folder.
files: BTreeMap<String, SerializedFile>By lower-case file name: level1, sharedassets1.assets, unity default resources, …; a bundled file by
the last segment of its node’s path (buildplayer-level_5.sharedassets).
folders: BTreeMap<String, PathBuf>The folder each loose file is in (its streamed resources are beside it); a bundled file has none.
bundles: Vec<Arc<Bundle>>The bundles files were read from, in the order given.
Implementations§
Source§impl Player
impl Player
Sourcepub fn open(dir: &Path, package: TypeTreePackage) -> Result<Self>
pub fn open(dir: &Path, package: TypeTreePackage) -> Result<Self>
The serialized files of dir (the <Game>_Data folder) and of its Resources folder, read with package’s
class layouts. Files of other kinds (resources, bundles, configs) are skipped.
A file whose header is a SerializedFile’s of a version this crate does not read is refused, not left out: a
player with such a file would otherwise read as one without it. Two files the player would name alike (they
differ by case, or one is in the data folder and one in Resources) are refused too.
Sourcepub fn open_with_bundles(
dir: &Path,
package: TypeTreePackage,
bundles: &[BundleSpec<'_>],
) -> Result<Self>
pub fn open_with_bundles( dir: &Path, package: TypeTreePackage, bundles: &[BundleSpec<'_>], ) -> Result<Self>
As Player::open, with the serialized files of bundles as well: a Big Walk style data.unity3d that holds
the player’s own files, or a level’s AssetBundle beside the loose ones. A bundled file is named like a loose one,
by the lower-cased last segment of its node’s path, and is refused the same way when another file has the name.
Its objects are read from the bundle by range as they are asked for, so a selection of a bundle costs the
metadata of its files. A file that stores its type trees decodes with them; others with the package.
Sourcepub fn file(&self, name: &str) -> Result<&SerializedFile>
pub fn file(&self, name: &str) -> Result<&SerializedFile>
The serialized file called name (lower case), or an error naming it.
Sourcepub fn class_id(&self, r: &ObjRef) -> Option<i32>
pub fn class_id(&self, r: &ObjRef) -> Option<i32>
The class id of an object (None: no such object).
Sourcepub fn class_name(&self, r: &ObjRef) -> Option<&str>
pub fn class_name(&self, r: &ObjRef) -> Option<&str>
The class name of an object: the root of the type tree its file stores for the object’s type, else the type tree package’s name for its class id.
Sourcepub fn decode(&self, r: &ObjRef) -> Result<Value>
pub fn decode(&self, r: &ObjRef) -> Result<Value>
Decode an object (its type tree must cover it; a MonoBehaviour’s base fields only).
Sourcepub fn script_fields(&self, r: &ObjRef) -> Result<Option<Value>>
pub fn script_fields(&self, r: &ObjRef) -> Result<Option<Value>>
A MonoBehaviour decoded whole, its script’s fields with its base fields, by the type tree its file stores for
its script’s type. None for a file that stores no type trees (a player’s: the script’s fields are
Player::behaviour’s bytes there) and for an object of another class. The tree must cover the object.
Sourcepub fn field(&self, r: &ObjRef, name: &str) -> Result<Option<Value>>
pub fn field(&self, r: &ObjRef, name: &str) -> Result<Option<Value>>
The field name of the object’s root struct alone (TypeTree::decode_field): None when its class has no
such field. The object need not decode whole, and a field stored early (m_Name) is read without the rest.
Sourcepub fn read_stream(&self, file: &str, info: &StreamingInfo) -> Result<Vec<u8>>
pub fn read_stream(&self, file: &str, info: &StreamingInfo) -> Result<Vec<u8>>
The bytes of a streamed resource (.resS, .resource) that an object of file names: from the file beside the
loose file, or from the node of its bundle that the path’s last segment names.
Sourcepub fn scenes(&self) -> Result<Vec<BuildScene>>
pub fn scenes(&self) -> Result<Vec<BuildScene>>
The scenes of the build, in BuildSettings’ order: scene i is the file level<i>. Ok(empty) for a player
without a globalgamemanagers or a BuildSettings (a player is never read for scenes it does not list).
Sourcepub fn behaviour(&self, r: &ObjRef) -> Result<(Value, Vec<u8>)>
pub fn behaviour(&self, r: &ObjRef) -> Result<(Value, Vec<u8>)>
A MonoBehaviour’s base fields and its script’s serialized bytes, which a stripped build has no type tree for.
Sourcepub fn render_pipeline(&self) -> Result<Option<RenderPipeline>>
pub fn render_pipeline(&self) -> Result<Option<RenderPipeline>>
The player’s RenderPipeline, from globalgamemanagers’ GraphicsSettings and QualitySettings; None when
the player has no GraphicsSettings.
Sourcepub fn urp_asset(&self, quality: Option<&str>) -> Result<Option<ObjRef>>
pub fn urp_asset(&self, quality: Option<&str>) -> Result<Option<ObjRef>>
The Universal Render Pipeline asset the quality level quality draws with (every level’s when none is named
and they all draw with one); Ok(None) when the level (or the levels) draw with no URP asset, or with more
than one where no level is named. An unknown level name is an error.
Sourcepub fn quality_levels(&self) -> Result<Vec<QualityLevel>>
pub fn quality_levels(&self) -> Result<Vec<QualityLevel>>
The quality levels of globalgamemanagers’ QualitySettings, in order, each with its name and the skin weights
it allows; none when the player has no QualitySettings. Which level is current at run time is not data a
consumer can read (see Player::build_quality), so a consumer states the level it wants where levels differ.
Sourcepub fn build_quality(&self) -> Result<Option<String>>
pub fn build_quality(&self) -> Result<Option<String>>
The name of the level the build was made with: the level m_CurrentQuality of the player’s QualitySettings
indexes (the three players read so far hold the top or only level). It is what the build states, not what the
game runs at: a game may change its quality level at run time. None when the player has no QualitySettings or
states no m_CurrentQuality; an index outside the levels is an error. (The per-platform default
m_PerPlatformDefaultQuality is not in a player: SkateBIRD, Sledding Game and PEAK carry none.)
Sourcepub fn colour_space(&self) -> Result<Option<ColourSpace>>
pub fn colour_space(&self) -> Result<Option<ColourSpace>>
The colour space the player renders in: its PlayerSettings’ m_ActiveColorSpace (ColourSpace). None when
the player has no PlayerSettings; a value other than 0 or 1 (the editor’s -1, uninitialised) is an error.
The field is read alone (Player::field), not the object whole: for the Unity 6000.3 players read so far
(Sledding Game, PEAK, Big Walk) the type tree package’s PlayerSettings layout covers 4 bytes fewer than the
build stores, the shortfall UnityPy’s layouts read too, while the fields before the colour space decode alike.