This commit is contained in:
Piotr Siuszko 2023-12-23 19:01:35 +01:00
parent b57200812c
commit 8a0552c4e7
2 changed files with 19 additions and 8 deletions

View File

@ -2,7 +2,18 @@
Simple CLI tool for unpacking the unitypackages. Also allows auto convert of the FBX files to GLTF during unpacking.
```bash
Program for unpacking unitypackages files
Usage: lwa_unity_unpack.exe [OPTIONS] --input <INPUT> --output <OUTPUT>
Options:
-i, --input <INPUT> .unitypackage file to extract
-o, --output <OUTPUT> target directory
-f, --fbx-to-gltf <FBX_TO_GLTF> optional- path to the tool that will auto convert fbx files to gltf during unpacking
-h, --help Print help
-V, --version Print version
```
## Example usage
`lwa_unity_unpack -i "C:\\PROJECTS\\lwa_unity_unpack\\POLYGON_Snow_Kit_Unity_2020_3_v1_4.unitypackage" -o "output" -f "C:\\tools\\FBX2glTF.exe"`

View File

@ -5,7 +5,7 @@ use flate2::read::GzDecoder;
use tar::Archive;
use std::collections::HashMap;
use std::ffi::OsStr;
use std::hash::Hash;
use std::io::prelude::*;
use std::io::BufReader;
use std::process::Command;
@ -71,7 +71,7 @@ fn main() {
if file_name == "pathname" {
let path = sub_entry.path();
let file = File::open(path).unwrap();
let mut buf_reader = BufReader::new(file);
let buf_reader = BufReader::new(file);
let line = buf_reader.lines().next();
match line {
Some(Ok(path)) => real_path = path,
@ -87,14 +87,14 @@ fn main() {
}
}
println!("Results:");
let mut mapping_arc = Arc::new(mapping);
let tmp_dir = Arc::new(tmp_dir.clone());
let output_dir = Arc::new(output_dir.clone());
let mapping_arc = Arc::new(mapping);
let tmp_dir = Arc::new(tmp_dir);
let output_dir = Arc::new(output_dir);
mapping_arc.par_iter().for_each(|(asset_hash, asset_path)| {
let path = Path::new(asset_path);
let source_asset = Path::new(&*tmp_dir).join(asset_hash).join("asset");
let result_path = output_dir.join(&path);
let result_path = output_dir.join(path);
process_directory(asset_hash, asset_path, &result_path);
check_source_asset_exists(&source_asset);
@ -129,7 +129,7 @@ fn main() {
let out_path = result_path.with_extension("");
println!("{:?}", &["--input", source_asset.to_str().unwrap(), "--output", out_path.to_str().unwrap()]);
let output = Command::new(tool)
.args(&["--input", source_asset.to_str().unwrap(), "-b", "--output", out_path.to_str().unwrap()])
.args(["--input", source_asset.to_str().unwrap(), "-b", "--output", out_path.to_str().unwrap()])
.output().unwrap();
let output_result = String::from_utf8_lossy(&output.stdout);
println!("output: {}", output_result);