pack and unpack *.unitypackage files, with Golang
go get github.com/piglig/go-unitypackage
package main
import "github.com/piglig/go-unitypackage"
func main() {
// the unitypackage path
packagePath := "D:\\test_unity\\test.unitypackage"
// the output assets path
assetsPath := "D:\\test_unity"
// Unpackage command will extract content from unitypackage.
err := unitypackage.UnPackage(packagePath, assetsPath)
if err != nil {
return
}
}
package main
import "github.com/piglig/go-unitypackage"
func main() {
// the assets directory
assetsPath := "D:\\test_unity"
// the output unitypackage path
packagePath := "D:\\test_unity\\package\\output.unitypackage"
// GeneratePackage command will generate a package from assets directory
err := unitypackage.GeneratePackage(assetsPath, packagePath)
if err != nil {
return
}
}
go-unitypackage command line tool to package or unpackage the unitypackage.
In order to use the tool, compile it using the following command
go install github.com/piglig/go-unitypackage/tools/go-unitypackage@latest
go-unitypackage [options] [arguments]
-act
: compress or decompress unitypackage (default "decompress")
-src
: compress or decompress the source directory-dest
: compress or decompress the destination directory
$:/usr/local/test_unity# ls
test.unitypackage
$:/usr/local/test_unity# go-unitypackage -src=test.unitypackage -dest=.
2023/04/04 10:59:55 target: /tmp/md5136041829/afd150e418c353f49b2bd5b68d0c43fa header: afd150e418c353f49b2bd5b68d0c43fa
2023/04/04 10:59:55 target: /tmp/md5136041829/afd150e418c353f49b2bd5b68d0c43fa/asset header: afd150e418c353f49b2bd5b68d0c43fa/asset
2023/04/04 10:59:55 target: /tmp/md5136041829/afd150e418c353f49b2bd5b68d0c43fa/asset.meta header: afd150e418c353f49b2bd5b68d0c43fa/asset.meta
2023/04/04 10:59:55 target: /tmp/md5136041829/afd150e418c353f49b2bd5b68d0c43fa/pathname header: afd150e418c353f49b2bd5b68d0c43fa/pathname
$:/usr/local/test_unity# ls
Assets Assets.meta test.unitypackage
$:/usr/local/test_unity# mkdir package
$:/usr/local/test_unity# go-unitypackage -act=compress -src=. -dest=package/out.unitypackage
$:/usr/local/test_unity/package# ls -l
total 4
-rw-r--r-- 1 root root 340 Apr 4 11:03 out.unitypackage
See the LICENSE file for license rights and limitations (MIT).