unitypackage

package module
v1.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2024 License: MIT Imports: 16 Imported by: 2

README

go-unitypackage

GoDoc Go Report Card

Overview

pack and unpack *.unitypackage files, with Golang

Installation

go get github.com/piglig/go-unitypackage

How to use

UnPackage
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
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
	}
}

Command Line Tool

go-unitypackage command line tool to package or unpackage the unitypackage.

Installation

In order to use the tool, compile it using the following command

go install github.com/piglig/go-unitypackage/tools/go-unitypackage@latest
Usage
go-unitypackage [options] [arguments]
Options
  • -act: compress or decompress unitypackage (default "decompress")
Arguments
  • -src: compress or decompress the source directory
  • -dest: compress or decompress the destination directory
Example
$:/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

License

See the LICENSE file for license rights and limitations (MIT).

Documentation

Overview

Package utils implements utility unitypackage for unpackage or package

Index

Constants

View Source
const DefaultUnityRootPath = "Assets"

Variables

This section is empty.

Functions

func GeneratePackage

func GeneratePackage(assetsRoot, outputPath string) error

func PreprocessAssets added in v1.0.5

func PreprocessAssets(assetsRoot string) error

PreprocessAssets preprocesses the assets at the given assets root directory.

func UnPackage

func UnPackage(packagePath, outputPath string) error

Types

This section is empty.

Directories

Path Synopsis
tools module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL