ExtractUnityPackage,py is a Python script for extracting the contents of a UnityPackage.
This script can be useful in the following situations:
- When you want to retrieve files from a UnityPackage without going through the time-consuming import process in Unity.
- When you already have files with the same path or GUID in your Unity project, and importing the UnityPackage would overwrite them.
Note:
- Python 3 is required to run this script. In most environments where Python 3 is installed, you should not need to install any additional libraries using tools like pip.
- This script has been tested only on Windows and may not work correctly in Linux or macOS environments.
Execute the script using the following command:
python ExtractUnityPackage.py [path to UnityPackage] [options]
The following are the command line options for this script:
-m
,--meta
: Output .meta files.-f
,--force
: When a folder with the same name as the UnityPackage already exists in the folder containing the UnityPackage, confirm whether to overwrite it. (You cannot decide on individual file overwrites.)
By outputting files with .meta files attached, the exported files, when placed in Unity's Assets folder, will have the same GUID as the ones in the UnityPackage. This makes it possible to use them for shaders, scripts, or other files that might be updated by importing another UnityPackage into the project or when multiple copies of the same file might exist within the project, potentially causing bugs.
On the other hand, if there is no problem with multiple textures existing in a Unity project, if you output them without a .meta file and put them in the Unity Assets folder, a GUID different from the one in Unitypackage will be assigned to the file. This is useful if you want to create multiple variants of a Unity project, or just want specific files included in a Unitypackage.
Please note that materials, Prefab, etc. that refer to other files by using the GUID in the .meta file may not be able to be referenced properly if they are output without a .meta file and imported.