v0.2.0
This commit is contained in:
parent
d174eb5e5c
commit
f68aeca902
|
|
@ -1,5 +1,11 @@
|
|||
# Changelog
|
||||
|
||||
## [0.2.0]
|
||||
|
||||
### Added
|
||||
|
||||
- Ignoring extensions during unpacking
|
||||
|
||||
## [0.1.0]
|
||||
|
||||
Initial version.
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "lwa_unity_unpack"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
edition = "2021"
|
||||
repository = "https://github.com/Leinnan/lwa_unity_unpack"
|
||||
homepage = "https://github.com/Leinnan/lwa_unity_unpack"
|
||||
|
|
|
|||
|
|
@ -16,12 +16,14 @@ 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
|
||||
--ignore-extensions <IGNORE_EXTENSIONS>
|
||||
optional- extensions that will be ignored during unpacking
|
||||
-h, --help Print help
|
||||
-V, --version Print version
|
||||
```
|
||||
|
||||
|
||||
`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"`
|
||||
`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" --ignore-extensions "mat" --ignore-extensions "prefab"`
|
||||
|
||||
|
||||
## Install
|
||||
|
|
|
|||
17
src/main.rs
17
src/main.rs
|
|
@ -26,6 +26,10 @@ struct Args {
|
|||
/// optional- path to the tool that will auto convert fbx files to gltf during unpacking
|
||||
#[arg(short, long)]
|
||||
fbx_to_gltf: Option<PathBuf>,
|
||||
|
||||
/// optional- extensions that will be ignored during unpacking
|
||||
#[arg(long, action = clap::ArgAction::Append)]
|
||||
ignore_extensions: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
pub fn extract_archive(archive_path: &Path, extract_to: &Path) -> io::Result<()> {
|
||||
|
|
@ -37,7 +41,8 @@ pub fn extract_archive(archive_path: &Path, extract_to: &Path) -> io::Result<()>
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let args = Args::parse();
|
||||
let args : Args = Args::parse();
|
||||
let ignored_extensions = args.ignore_extensions.unwrap_or(vec![]);
|
||||
let archive_path = Path::new(&args.input);
|
||||
let tmp_dir = Path::new("./tmp_dir");
|
||||
let output_dir = Path::new(&args.output);
|
||||
|
|
@ -64,6 +69,7 @@ fn main() {
|
|||
let asset = entry.file_name().into_string().unwrap();
|
||||
if root_file.is_dir() {
|
||||
let mut real_path= String::new() ;
|
||||
let mut extension = None;
|
||||
let mut has_asset = false;
|
||||
for sub_entry in fs::read_dir(root_file.clone()).unwrap() {
|
||||
let sub_entry = sub_entry.unwrap();
|
||||
|
|
@ -74,14 +80,19 @@ fn main() {
|
|||
let buf_reader = BufReader::new(file);
|
||||
let line = buf_reader.lines().next();
|
||||
match line {
|
||||
Some(Ok(path)) => real_path = path,
|
||||
Some(Ok(path)) => {
|
||||
real_path = path;
|
||||
if let Some(e) = Path::new(&real_path).extension().and_then(OsStr::to_str) {
|
||||
extension = Some(String::from(e));
|
||||
}
|
||||
},
|
||||
_ => continue,
|
||||
}
|
||||
} else if file_name == "asset" {
|
||||
has_asset = true;
|
||||
}
|
||||
}
|
||||
if has_asset {
|
||||
if has_asset && !ignored_extensions.contains(&extension.unwrap_or_default()){
|
||||
mapping.insert(asset, real_path);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue