Skip to content

Commit db0320e

Browse files
committed
Initial commit
1 parent 04270fd commit db0320e

34 files changed

+28241
-0
lines changed

.gitattributes

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
*.java text diff=java
2+
*.properties text
3+
*.xml text
4+
*.ini text
5+
*.md text
6+
*.txt text
7+
*.form text eol=lf
8+
9+
*.class binary
10+
*.jar binary
11+
*.png binary
12+
*.ico binary
13+
*.xcf binary

.github/BupV.png

81.6 KB
Loading

.github/Unity.png

41.8 KB
Loading

.github/tar-directories.png

25.4 KB
Loading

.github/tar-directory-contents.png

5.59 KB
Loading

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/target/
2+
/.idea/
3+
/nbactions.xml
4+
/history.ini
5+
/dependency-reduced-pom.xml

CONTRIBUTING.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Disclaimer
2+
3+
This is a hobby project. I work on it for fun.
4+
If I'm not having fun, I probably won't do it :)
5+
You're welcome to report issues, or create pull requests.
6+
But if they're not useful to me, I probably won't respond
7+
(though they may help others who run into them).
8+
If you really want to see enhancements, fork it and have fun. :)
9+
10+
# Development environment
11+
12+
Any Java IDE of your choice. However the main window form was creating using Netbeans form designer, so you'll want that to edit the GUI.
13+
14+
# Building
15+
16+
It's a standard Maven project. Run
17+
```
18+
mvn clean install
19+
```
20+
It will generate a self-contained fat jar in the `/target/` directory that is ready to use.
21+
22+
# Reporting issues
23+
24+
Use issue reporting best practices. Provide these 3 things:
25+
26+
1. Steps to reproduce the issue
27+
2. Expected behavior
28+
3. Actual behavior
29+
30+
# Pull requests
31+
32+
Check your code against SpotBugs, PMD, or IntelliJ inspections. Fix any issues.
33+
34+
Anything that is merged will be a fast-forward or squash-merge.

LICENSE.txt

Lines changed: 661 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Basic .unitypackage Viewer
2+
3+
I just wanted a simple tool to do the following:
4+
5+
* Browse the tree of a `.unitypackage` file
6+
* Extract some individual files
7+
* All without having to start Unity
8+
9+
So I threw this together for my own use. Maybe it could be helpful to others.
10+
11+
This is a Java program requiring Java 8 or higher.
12+
13+
14+
# How to use
15+
16+
![](.github/BupV.png?raw=true)
17+
18+
* Run with Java
19+
* Accepts a `.unitypackage` as a program argument to open immediately
20+
* Open `.unitypackage` files using the Open button, or drag and drop a `.unitypackage` onto the window
21+
* Search by name or GUID in the text box and press Enter or the Search button
22+
* Expand/Collapse the tree
23+
* Files with a preview will appear in the preview box
24+
* Extract the selected item into the same directory as the `.unitypackage`.
25+
The directory will be opened in your OS file viewer.
26+
* Right-click to copy name, size, or GUID
27+
* History.ini saves the last directory used
28+
29+
30+
# Disclaimers
31+
32+
* This is *beta* quality software. No rigorous testing has been done. It probably has bugs. Only tested with data as I make use of it.
33+
34+
* All I know about the `.unitypackage` file format came from examining several files, and reading code from some existing tools.
35+
I didn't read any specification (assuming there is one). There could certainly be edge cases this misses.
36+
37+
# The `.unitypackage` file format
38+
39+
A `.unitypackage` is just a compressed TAR archive.
40+
Inside it contains several root directories.
41+
Each directory name is a GUID.
42+
43+
![](.github/tar-directories.png?raw=true)
44+
45+
46+
Inside each of them is the contents of the asset with that GUID.
47+
Specifically, each GUID directory contains some of these 4 files.
48+
49+
![](.github/tar-directory-contents.png?raw=true)
50+
51+
* `pathname` First line of text is the full path of the asset where it will appear when imported into Unity.
52+
* `asset.meta` The corresponding .meta file.
53+
* `asset` Contains the actual asset payload. Won't exist for directories.
54+
* `preview.png` Optional preview of some types of assets.
55+
56+
57+
It's not difficult to build up the structure of what's shown when you import into unity.
58+
59+
As shown in Unity:
60+
61+
![](.github/Unity.png?raw=true)
62+
63+
As shown in this tool:
64+
65+
![](.github/BupV.png?raw=true)
66+
67+
# Existing open source tools I found
68+
69+
### https://gist.github.com/yasirkula/dfc43134fbfefb820d0adbc5d7c25fb3
70+
71+
A very nice Unity script to explore `.unitypackages`.
72+
73+
### https://github.com/Switch-9867/UnitypackgeExtractor
74+
75+
C# command-line tool.
76+
77+
### https://github.com/Cobertos/unitypackage_extractor
78+
79+
Python command-line tool. Its associated pypi package at https://pypi.org/project/unitypackage-extractor/
80+

icon/1033_Icon_103.ico

44.3 KB
Binary file not shown.
Loading

icon/BupVIcon.ico

112 KB
Binary file not shown.

icon/BupVIcon.xcf

284 KB
Binary file not shown.

pom.xml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>m35-projects</groupId>
5+
<artifactId>unity-package-viewer</artifactId>
6+
<version>0.0.1</version>
7+
<packaging>jar</packaging>
8+
<properties>
9+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
10+
<maven.compiler.source>1.8</maven.compiler.source>
11+
<maven.compiler.target>1.8</maven.compiler.target>
12+
</properties>
13+
14+
<dependencies>
15+
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-compress -->
16+
<dependency>
17+
<groupId>org.apache.commons</groupId>
18+
<artifactId>commons-compress</artifactId>
19+
<version>1.26.2</version>
20+
</dependency>
21+
</dependencies>
22+
23+
<build>
24+
<resources>
25+
<resource><directory>src/main/resources</directory></resource>
26+
<resource><directory>src/main/java</directory></resource>
27+
<resource>
28+
<directory>src/main/misc</directory>
29+
<filtering>true</filtering>
30+
</resource>
31+
<resource>
32+
<directory>.</directory>
33+
<includes><include>LICENSE.txt</include></includes>
34+
</resource>
35+
</resources>
36+
<plugins>
37+
<plugin>
38+
<groupId>org.apache.maven.plugins</groupId>
39+
<artifactId>maven-shade-plugin</artifactId>
40+
<executions>
41+
<execution>
42+
<phase>package</phase>
43+
<goals>
44+
<goal>shade</goal>
45+
</goals>
46+
<configuration>
47+
<finalName>UnityPackageViewer-${project.version}</finalName>
48+
<minimizeJar>true</minimizeJar>
49+
50+
<!-- Choose my MANIFEST.MF as the winner -->
51+
<filters>
52+
<filter>
53+
<artifact>${project.groupId}:${project.artifactId}</artifact>
54+
<includes>
55+
<include>**/*</include>
56+
</includes>
57+
</filter>
58+
<filter>
59+
<artifact>*:*</artifact>
60+
<excludes>
61+
<exclude>META-INF/MANIFEST.MF</exclude>
62+
</excludes>
63+
</filter>
64+
</filters>
65+
66+
<transformers>
67+
<transformer implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer"/>
68+
<transformer implementation="org.apache.maven.plugins.shade.resource.ApacheNoticeResourceTransformer"/>
69+
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
70+
<mainClass>unitypackage.viewer.Main</mainClass>
71+
</transformer>
72+
</transformers>
73+
</configuration>
74+
</execution>
75+
</executions>
76+
</plugin>
77+
</plugins>
78+
</build>
79+
80+
</project>
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* Basic .unitypackage Viewer
3+
* Copyright (C) 2024 Michael Sabin
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU Affero General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU Affero General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU Affero General Public License
16+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
17+
*/
18+
19+
package unitypackage.model;
20+
21+
import java.awt.image.BufferedImage;
22+
import java.nio.file.Path;
23+
import java.nio.file.Paths;
24+
import java.util.Date;
25+
26+
/**
27+
* An asset as it would appear in the tree of stuff you see when you import a .unitypackage into unity.
28+
* This could be a directory or a file.
29+
*/
30+
public class UnityAsset {
31+
32+
private final UnityAssetBuilder source;
33+
34+
UnityAsset(UnityAssetBuilder source) {
35+
this.source = source;
36+
}
37+
38+
public String getFullPath() {
39+
return source.getPathname_firstLine();
40+
}
41+
42+
public Path getFullPathAsPath() {
43+
return Paths.get(getFullPath());
44+
}
45+
46+
public Path getFileNameAsPath() {
47+
return getFullPathAsPath().getFileName();
48+
}
49+
50+
public String getFileName() {
51+
return getFileNameAsPath().toString();
52+
}
53+
54+
public long getSize() {
55+
return source.getAsset_fileSize();
56+
}
57+
58+
public String getGuid() {
59+
return source.getAsset_meta_guid();
60+
}
61+
62+
public String getDirectoryGuid() {
63+
return source.getGuidBaseDirectory();
64+
}
65+
66+
public BufferedImage getPreview() {
67+
return source.getPreview();
68+
}
69+
70+
public boolean isProbablyDirectory() {
71+
return source.getRawPathTo_asset_file() == null;
72+
}
73+
74+
String getTarPathOf_asset_File() {
75+
return source.getRawPathTo_asset_file();
76+
}
77+
78+
public Date getDateModified() {
79+
return source.getAsset_dateModified();
80+
}
81+
82+
@Override
83+
public String toString() {
84+
return "UnityAsset{" + getFullPath() + '}';
85+
}
86+
}

0 commit comments

Comments
 (0)