pub struct Environment { /* private fields */ }Expand description
Unified environment for managing Unity assets
Implementations§
Source§impl Environment
impl Environment
Sourcepub fn bundle_container_entries<P: AsRef<Path>>(
&self,
bundle_path: P,
) -> Result<Vec<BundleContainerEntry>>
pub fn bundle_container_entries<P: AsRef<Path>>( &self, bundle_path: P, ) -> Result<Vec<BundleContainerEntry>>
Extract best-effort m_Container entries from a loaded bundle source path.
This scans for AssetBundle objects (class id 142) inside the bundle and parses them to find
m_Container entries.
pub fn bundle_container_entries_source( &self, bundle_source: &BinarySource, ) -> Result<Vec<BundleContainerEntry>>
Sourcepub fn find_bundle_container_entries(
&self,
pattern: &str,
) -> Vec<BundleContainerEntry>
pub fn find_bundle_container_entries( &self, pattern: &str, ) -> Vec<BundleContainerEntry>
Find container entries across all loaded bundles whose asset_path contains pattern.
Sourcepub fn find_binary_object_keys_in_bundle_container(
&self,
pattern: &str,
) -> Vec<(String, BinaryObjectKey)>
pub fn find_binary_object_keys_in_bundle_container( &self, pattern: &str, ) -> Vec<(String, BinaryObjectKey)>
Find resolved BinaryObjectKeys from bundle containers by path substring.
Source§impl Environment
impl Environment
Source§impl Environment
impl Environment
Sourcepub fn binary_object_infos(&self) -> impl Iterator<Item = BinaryObjectRef<'_>>
pub fn binary_object_infos(&self) -> impl Iterator<Item = BinaryObjectRef<'_>>
Iterate binary object references across all loaded bundles and standalone serialized files.
Sourcepub fn binary_sources(&self) -> Vec<(BinarySourceKind, BinarySource)>
pub fn binary_sources(&self) -> Vec<(BinarySourceKind, BinarySource)>
List all loaded binary sources (standalone serialized files + bundles).
Sourcepub fn find_binary_objects(&self, path_id: i64) -> Vec<BinaryObjectRef<'_>>
pub fn find_binary_objects(&self, path_id: i64) -> Vec<BinaryObjectRef<'_>>
Find binary objects by path_id across all loaded assets/bundles.
Note: path_id is unique within a single SerializedFile, but not globally unique across files.
Sourcepub fn find_binary_object(&self, path_id: i64) -> Option<BinaryObjectRef<'_>>
pub fn find_binary_object(&self, path_id: i64) -> Option<BinaryObjectRef<'_>>
Find the first matching binary object by path_id (best-effort).
Sourcepub fn find_binary_objects_in_source<P: AsRef<Path>>(
&self,
source: P,
path_id: i64,
) -> Vec<BinaryObjectRef<'_>>
pub fn find_binary_objects_in_source<P: AsRef<Path>>( &self, source: P, path_id: i64, ) -> Vec<BinaryObjectRef<'_>>
Find binary objects by path_id within a specific loaded source (bundle path or .assets path).
Sourcepub fn find_binary_objects_in_source_id(
&self,
source: &BinarySource,
path_id: i64,
) -> Vec<BinaryObjectRef<'_>>
pub fn find_binary_objects_in_source_id( &self, source: &BinarySource, path_id: i64, ) -> Vec<BinaryObjectRef<'_>>
Find binary objects by path_id within a specific loaded source (including WebFile entries).
Sourcepub fn find_binary_object_in_source<P: AsRef<Path>>(
&self,
source: P,
path_id: i64,
) -> Option<BinaryObjectRef<'_>>
pub fn find_binary_object_in_source<P: AsRef<Path>>( &self, source: P, path_id: i64, ) -> Option<BinaryObjectRef<'_>>
Find the first binary object by path_id within a specific source.
pub fn find_binary_object_in_source_id( &self, source: &BinarySource, path_id: i64, ) -> Option<BinaryObjectRef<'_>>
Sourcepub fn find_binary_object_in_bundle_asset<P: AsRef<Path>>(
&self,
bundle_path: P,
asset_index: usize,
path_id: i64,
) -> Option<BinaryObjectRef<'_>>
pub fn find_binary_object_in_bundle_asset<P: AsRef<Path>>( &self, bundle_path: P, asset_index: usize, path_id: i64, ) -> Option<BinaryObjectRef<'_>>
Find a binary object by path_id within a specific bundle + asset index.
pub fn find_binary_object_in_bundle_asset_source( &self, bundle_source: &BinarySource, asset_index: usize, path_id: i64, ) -> Option<BinaryObjectRef<'_>>
Sourcepub fn find_binary_object_keys(&self, path_id: i64) -> Vec<BinaryObjectKey>
pub fn find_binary_object_keys(&self, path_id: i64) -> Vec<BinaryObjectKey>
Find globally-unique keys for all matching objects by path_id (best-effort).
Sourcepub fn find_binary_object_keys_in_source<P: AsRef<Path>>(
&self,
source: P,
path_id: i64,
) -> Vec<BinaryObjectKey>
pub fn find_binary_object_keys_in_source<P: AsRef<Path>>( &self, source: P, path_id: i64, ) -> Vec<BinaryObjectKey>
Find globally-unique keys for all matching objects by path_id within a specific source.
Sourcepub fn read_binary_object_key(
&self,
key: &BinaryObjectKey,
) -> Result<UnityObject>
pub fn read_binary_object_key( &self, key: &BinaryObjectKey, ) -> Result<UnityObject>
Read a UnityObject from a globally-unique key.
Sourcepub fn peek_binary_object_name(
&self,
key: &BinaryObjectKey,
) -> Result<Option<String>>
pub fn peek_binary_object_name( &self, key: &BinaryObjectKey, ) -> Result<Option<String>>
Best-effort peek of m_Name/name for a binary object key.
This uses a TypeTree prefix fast path (when possible) and returns Ok(None) when the
object has no TypeTree or does not expose a name field.
Source§impl Environment
impl Environment
Sourcepub fn resolve_binary_pptr(
&self,
context: &BinaryObjectRef<'_>,
file_id: i32,
path_id: i64,
) -> Option<BinaryObjectKey>
pub fn resolve_binary_pptr( &self, context: &BinaryObjectRef<'_>, file_id: i32, path_id: i64, ) -> Option<BinaryObjectKey>
Resolve a Unity PPtr (fileID, pathID) into a globally-unique object key.
Notes:
file_id == 0points to the sameSerializedFileas the context object.file_id > 0indexes into the context file’sexternalslist (Unity convention:file_id - 1).- External resolution is best-effort and currently only matches already-loaded standalone serialized files.
Sourcepub fn read_binary_pptr(
&self,
context: &BinaryObjectRef<'_>,
file_id: i32,
path_id: i64,
) -> Result<UnityObject>
pub fn read_binary_pptr( &self, context: &BinaryObjectRef<'_>, file_id: i32, path_id: i64, ) -> Result<UnityObject>
Resolve and parse a Unity PPtr (fileID, pathID) using a context object for external mapping.
Source§impl Environment
impl Environment
Sourcepub fn read_bundle_stream_data<P: AsRef<Path>>(
&self,
bundle_path: P,
stream_path: &str,
offset: u64,
size: u32,
) -> Result<Vec<u8>>
pub fn read_bundle_stream_data<P: AsRef<Path>>( &self, bundle_path: P, stream_path: &str, offset: u64, size: u32, ) -> Result<Vec<u8>>
Read streamed resource bytes from a loaded bundle.
This is primarily used for AudioClip / Texture2D stream data (m_StreamData) when the
referenced resource file is contained inside the same bundle (e.g. .resS / .resource).
pub fn read_bundle_stream_data_source( &self, bundle_source: &BinarySource, stream_path: &str, offset: u64, size: u32, ) -> Result<Vec<u8>>
Sourcepub fn read_stream_data<P: AsRef<Path>>(
&self,
source_path: P,
source_kind: BinarySourceKind,
stream_path: &str,
offset: u64,
size: u32,
) -> Result<Vec<u8>>
pub fn read_stream_data<P: AsRef<Path>>( &self, source_path: P, source_kind: BinarySourceKind, stream_path: &str, offset: u64, size: u32, ) -> Result<Vec<u8>>
Read streamed resource bytes (best-effort) using the current environment context.
Resolution strategy:
- If
source_kindisAssetBundle, try to read from resource nodes inside the same bundle. - Fall back to reading from the filesystem (same directory /
StreamingAssets/), which matches UnityPy’sResourceReader-like behavior.
pub fn read_stream_data_source( &self, source: &BinarySource, source_kind: BinarySourceKind, stream_path: &str, offset: u64, size: u32, ) -> Result<Vec<u8>>
Sourcepub fn read_stream_data_from_fs<P: AsRef<Path>>(
&self,
source_path: P,
stream_path: &str,
offset: u64,
size: u32,
) -> Result<Vec<u8>>
pub fn read_stream_data_from_fs<P: AsRef<Path>>( &self, source_path: P, stream_path: &str, offset: u64, size: u32, ) -> Result<Vec<u8>>
Read streamed resource bytes from the filesystem (best-effort).
This is useful when StreamedResource.m_Source points to an external .resS/.resource
file that is not embedded in the current bundle.
Source§impl Environment
impl Environment
pub fn with_options(options: EnvironmentOptions) -> Self
pub fn set_reporter(&mut self, reporter: Option<Arc<dyn EnvironmentReporter>>)
pub fn set_type_tree_registry( &mut self, registry: Option<Arc<dyn TypeTreeRegistry>>, )
pub fn options(&self) -> EnvironmentOptions
pub fn warnings(&self) -> Vec<EnvironmentWarning>
pub fn take_warnings(&self) -> Vec<EnvironmentWarning>
Sourcepub fn yaml_objects(&self) -> impl Iterator<Item = &UnityClass>
pub fn yaml_objects(&self) -> impl Iterator<Item = &UnityClass>
Iterate YAML Unity objects.
Sourcepub fn find_yaml_by_anchor(&self, anchor: &str) -> Option<&UnityClass>
pub fn find_yaml_by_anchor(&self, anchor: &str) -> Option<&UnityClass>
Find a YAML object by its YAML anchor (the &<id> part).
Sourcepub fn objects(&self) -> Box<dyn Iterator<Item = EnvironmentObjectRef<'_>> + '_>
pub fn objects(&self) -> Box<dyn Iterator<Item = EnvironmentObjectRef<'_>> + '_>
Iterate all objects (YAML + binary) as lightweight references.
Sourcepub fn binary_objects(&self) -> impl Iterator<Item = Result<UnityObject>> + '_
pub fn binary_objects(&self) -> impl Iterator<Item = Result<UnityObject>> + '_
Iterate parsed binary UnityObjects (best-effort).
Sourcepub fn filter_by_class(&self, class_name: &str) -> Vec<&UnityClass>
pub fn filter_by_class(&self, class_name: &str) -> Vec<&UnityClass>
Filter YAML objects by class name.
Sourcepub fn yaml_documents(&self) -> &HashMap<PathBuf, YamlDocument>
pub fn yaml_documents(&self) -> &HashMap<PathBuf, YamlDocument>
Get loaded YAML documents
Sourcepub fn binary_assets(&self) -> &HashMap<BinarySource, SerializedFile>
pub fn binary_assets(&self) -> &HashMap<BinarySource, SerializedFile>
Get loaded standalone SerializedFiles.
Sourcepub fn bundles(&self) -> &HashMap<BinarySource, AssetBundle>
pub fn bundles(&self) -> &HashMap<BinarySource, AssetBundle>
Get loaded AssetBundles.