use cursebreaker_parser::UnityFile; use std::path::Path; fn main() { // Parse a Unity prefab file let prefab_path = Path::new("data/tests/unity-sampleproject/PiratePanic/Assets/PiratePanic/Prefabs/Menu/Battle/Hand/CardGrabber.prefab"); if !prefab_path.exists() { eprintln!("Error: Unity sample project not found."); eprintln!("Please ensure the git submodule is initialized:"); eprintln!(" git submodule update --init --recursive"); return; } // Parse the file match UnityFile::from_path(prefab_path) { Ok(file) => { println!("Successfully parsed: {:?}", file.path.file_name().unwrap()); println!("Found {} documents\n", file.documents.len()); // List all documents for (i, doc) in file.documents.iter().enumerate() { println!("Document {}: {} (Type ID: {}, File ID: {})", i + 1, doc.class_name, doc.type_id, doc.file_id ); } println!(); // Find all GameObjects let game_objects = file.get_documents_by_class("GameObject"); println!("Found {} GameObjects:", game_objects.len()); for go in game_objects { if let Some(go_props) = go.get("GameObject") { if let Some(props) = go_props.as_object() { if let Some(name) = props.get("m_Name").and_then(|v| v.as_str()) { println!(" - {}", name); } } } } println!(); // Find all Transforms let transforms = file.get_documents_by_type(224); // RectTransform type ID println!("Found {} RectTransforms", transforms.len()); // Look up a specific document by file ID if let Some(first_doc) = file.documents.first() { let file_id = first_doc.file_id; if let Some(found) = file.get_document(file_id) { println!("\nLooking up document by file ID {}:", file_id); println!(" Class: {}", found.class_name); println!(" Properties: {} keys", found.properties.len()); } } } Err(e) => { eprintln!("Error parsing file: {}", e); } } }