Skip to main content

Player

Struct Player 

Source
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: PathBuf

The 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

Source

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.

Source

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.

Source

pub fn file(&self, name: &str) -> Result<&SerializedFile>

The serialized file called name (lower case), or an error naming it.

Source

pub fn class_id(&self, r: &ObjRef) -> Option<i32>

The class id of an object (None: no such object).

Source

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.

Source

pub fn decode(&self, r: &ObjRef) -> Result<Value>

Decode an object (its type tree must cover it; a MonoBehaviour’s base fields only).

Source

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.

Source

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.

Source

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.

Source

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).

Source

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.

Source

pub fn render_pipeline(&self) -> Result<Option<RenderPipeline>>

The player’s RenderPipeline, from globalgamemanagers’ GraphicsSettings and QualitySettings; None when the player has no GraphicsSettings.

Source

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.

Source

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.

Source

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.)

Source

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.

Source

pub fn resolve(&self, file: &str, pptr: &Value) -> Result<Option<ObjRef>>

The object a PPtr (m_FileID, m_PathID) found in file points at; None for a null pointer.

Trait Implementations§

Source§

impl Debug for Player

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.