pub struct PythonLikeUnityDocument { /* private fields */ }Expand description
Python-like wrapper for Unity documents
This provides an API similar to the Python reference library:
doc = UnityDocument.load_yaml("file.asset")
entry = doc.entry
entry.m_Name = "NewName"
doc.dump_yaml()Implementations§
Source§impl PythonLikeUnityDocument
impl PythonLikeUnityDocument
Sourcepub fn load_yaml<P: AsRef<Path>>(
file_path: P,
try_preserve_types: bool,
) -> Result<Self>
pub fn load_yaml<P: AsRef<Path>>( file_path: P, try_preserve_types: bool, ) -> Result<Self>
Load a Unity YAML file (similar to Python’s UnityDocument.load_yaml)
§Arguments
file_path- Path to the Unity YAML filetry_preserve_types- Whether to preserve original types (similar to Python’s flag)
§Examples
use unity_asset_yaml::python_like_api::PythonLikeUnityDocument;
let doc = PythonLikeUnityDocument::load_yaml("ProjectSettings.asset", false)?;Sourcepub fn entry(&self) -> Option<PythonLikeUnityClass<'_>>
pub fn entry(&self) -> Option<PythonLikeUnityClass<'_>>
Get the first entry (similar to Python’s doc.entry)
Sourcepub fn entries(&self) -> Vec<PythonLikeUnityClass<'_>>
pub fn entries(&self) -> Vec<PythonLikeUnityClass<'_>>
Get all entries (similar to Python’s doc.entries)
Sourcepub fn filter(
&self,
class_names: Option<&[&str]>,
attributes: Option<&[&str]>,
) -> Vec<PythonLikeUnityClass<'_>>
pub fn filter( &self, class_names: Option<&[&str]>, attributes: Option<&[&str]>, ) -> Vec<PythonLikeUnityClass<'_>>
Filter entries by class names and attributes (similar to Python’s doc.filter)
§Examples
use unity_asset_yaml::python_like_api::PythonLikeUnityDocument;
let doc = PythonLikeUnityDocument::load_yaml("scene.unity", false)?;
// Find all GameObjects
let gameobjects = doc.filter(Some(&["GameObject"]), None);
// Find objects with m_Enabled property
let enabled_objects = doc.filter(None, Some(&["m_Enabled"]));Sourcepub fn get(
&self,
class_name: Option<&str>,
attributes: Option<&[&str]>,
) -> Result<PythonLikeUnityClass<'_>>
pub fn get( &self, class_name: Option<&str>, attributes: Option<&[&str]>, ) -> Result<PythonLikeUnityClass<'_>>
Get a single entry by class name and attributes (similar to Python’s doc.get)
Sourcepub fn dump_yaml_to<P: AsRef<Path>>(&self, file_path: P) -> Result<()>
pub fn dump_yaml_to<P: AsRef<Path>>(&self, file_path: P) -> Result<()>
Save to a specific file (similar to Python’s doc.dump_yaml(file_path=“…”))
Sourcepub fn inner(&self) -> &YamlDocument
pub fn inner(&self) -> &YamlDocument
Get the underlying YamlDocument for advanced operations
Sourcepub fn inner_mut(&mut self) -> &mut YamlDocument
pub fn inner_mut(&mut self) -> &mut YamlDocument
Get mutable access to the underlying YamlDocument
Auto Trait Implementations§
impl Freeze for PythonLikeUnityDocument
impl RefUnwindSafe for PythonLikeUnityDocument
impl Send for PythonLikeUnityDocument
impl Sync for PythonLikeUnityDocument
impl Unpin for PythonLikeUnityDocument
impl UnwindSafe for PythonLikeUnityDocument
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more