Created
March 13, 2022 15:14
-
-
Save quabug/2bac2dc8a042bd472107b12d99bdf125 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
tmp_dir=`mktemp -d -t unitypackage-XXXXXXXX` | |
package_dir=$1 | |
output_path=${2:-'output.unitypackage'} | |
function make_meta_directory() { | |
meta_file=$1 | |
asset_file=${meta_file%.*} | |
guid=`yq e '.guid' $meta_file` | |
dir="$tmp_dir/$guid" | |
mkdir $dir | |
cp $meta_file $dir/asset.meta | |
echo $asset_file > $dir/pathname | |
if [[ -f $asset_file ]]; then | |
cp $asset_file $dir/asset | |
elif [[ ! -d $asset_file ]]; then | |
rm -fr $dir | |
echo "cannot found corresponding asset file $asset_file" >&2 | |
fi | |
} | |
for meta_file in `find ./$package_dir -name "*.meta"`; do make_meta_directory "${meta_file}"; done | |
cd $tmp_dir | |
tar -cf archtemp.tar * | |
cd - > /dev/null | |
gzip -c $tmp_dir/archtemp.tar > $output_path | |
echo $output_path |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment