blob: e52b210a5a395e8eac0acb7cbf0234d42e0efbd0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
use std::{
env::{args, var},
fs::File,
io::BufReader,
};
use unity_tools::{assetbundle::AssetBundle, classes::transform::Transform};
fn main() -> anyhow::Result<()> {
env_logger::init_from_env("LOG");
let file = BufReader::new(File::open(args().nth(1).unwrap()).unwrap());
let mut bundle = AssetBundle::open(file, "samples")?;
let draw_children = var("DRAW_CHILDREN").is_ok();
println!("digraph {{");
for ob in bundle
.all_toplevel_of_class("Transform")
.into_iter()
.chain(bundle.all_toplevel_of_class("RectTransform"))
{
let i = ob.path_id;
let tr = ob.load(&mut bundle)?.parse::<Transform>()?;
println!("n{i} [label=\"\", color=blue];");
if !tr.gameobject.is_null() {
let j = tr.gameobject.path_id;
let go = tr.gameobject.load(&mut bundle)?;
println!("g{j} [label={:?}]", go.name);
println!("n{i} -> g{j}")
}
if !tr.father.is_null() {
assert_eq!(tr.father.file_id, 0);
let j = tr.father.path_id;
println!("n{j} -> n{i};")
}
if draw_children {
for ch in tr.children {
assert_eq!(ch.file_id, 0);
let j = ch.path_id;
println!("n{i} -> n{j} [color=red];")
}
}
}
println!("}}");
Ok(())
}
|