├── .gitignore ├── .nuget ├── NuGet.Config ├── NuGet.exe └── NuGet.targets ├── BAG.UnityPackage.Console.sln ├── README.md ├── chocolatey ├── tools │ └── chocolateyInstall.ps1 └── upackx.nuspec └── src └── BAG.UnityPackage.Console ├── App.config ├── BAG.UnityPackage.Console.csproj ├── Options.cs ├── Program.cs ├── Properties └── AssemblyInfo.cs ├── lic.txt └── packages.config /.gitignore: -------------------------------------------------------------------------------- 1 | # Build Folders (you can keep bin if you'd like, to store dlls and pdbs) 2 | [Bb]in/ 3 | [Oo]bj/ 4 | 5 | # mstest test results 6 | TestResults 7 | 8 | ## Ignore Visual Studio temporary files, build results, and 9 | ## files generated by popular Visual Studio add-ons. 10 | 11 | # User-specific files 12 | *.suo 13 | *.user 14 | *.sln.docstates 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Rr]elease/ 19 | x64/ 20 | *_i.c 21 | *_p.c 22 | *.ilk 23 | *.meta 24 | *.obj 25 | *.pch 26 | *.pdb 27 | *.pgc 28 | *.pgd 29 | *.rsp 30 | *.sbr 31 | *.tlb 32 | *.tli 33 | *.tlh 34 | *.tmp 35 | *.log 36 | *.vspscc 37 | *.vssscc 38 | .builds 39 | 40 | # Visual C++ cache files 41 | ipch/ 42 | *.aps 43 | *.ncb 44 | *.opensdf 45 | *.sdf 46 | 47 | # Visual Studio profiler 48 | *.psess 49 | *.vsp 50 | *.vspx 51 | 52 | # Guidance Automation Toolkit 53 | *.gpState 54 | 55 | # ReSharper is a .NET coding add-in 56 | _ReSharper* 57 | 58 | # NCrunch 59 | *.ncrunch* 60 | .*crunch*.local.xml 61 | 62 | # Installshield output folder 63 | [Ee]xpress 64 | 65 | # DocProject is a documentation generator add-in 66 | DocProject/buildhelp/ 67 | DocProject/Help/*.HxT 68 | DocProject/Help/*.HxC 69 | DocProject/Help/*.hhc 70 | DocProject/Help/*.hhk 71 | DocProject/Help/*.hhp 72 | DocProject/Help/Html2 73 | DocProject/Help/html 74 | 75 | # Click-Once directory 76 | publish 77 | 78 | # Publish Web Output 79 | *.Publish.xml 80 | 81 | # NuGet Packages Directory 82 | packages 83 | 84 | # Windows Azure Build Output 85 | csx 86 | *.build.csdef 87 | 88 | # Windows Store app package directory 89 | AppPackages/ 90 | 91 | # Others 92 | [Bb]in 93 | [Oo]bj 94 | sql 95 | TestResults 96 | [Tt]est[Rr]esult* 97 | *.Cache 98 | ClientBin 99 | [Ss]tyle[Cc]op.* 100 | ~$* 101 | *.dbmdl 102 | Generated_Code #added for RIA/Silverlight projects 103 | 104 | # Backup & report files from converting an old project file to a newer 105 | # Visual Studio version. Backup files are not needed, because we have git ;-) 106 | _UpgradeReport_Files/ 107 | Backup*/ 108 | UpgradeLog*.XML 109 | -------------------------------------------------------------------------------- /.nuget/NuGet.Config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.nuget/NuGet.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bradgearon/unity-3d-package-extract/a35da9a6170b239eeef8a3d4171d6476b5a13405/.nuget/NuGet.exe -------------------------------------------------------------------------------- /.nuget/NuGet.targets: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | $(MSBuildProjectDirectory)\..\ 5 | 6 | 7 | false 8 | 9 | 10 | false 11 | 12 | 13 | true 14 | 15 | 16 | false 17 | 18 | 19 | 20 | 21 | 22 | 26 | 27 | 28 | 29 | 30 | $([System.IO.Path]::Combine($(SolutionDir), ".nuget")) 31 | $([System.IO.Path]::Combine($(ProjectDir), "packages.config")) 32 | 33 | 34 | 35 | 36 | $(SolutionDir).nuget 37 | packages.config 38 | 39 | 40 | 41 | 42 | $(NuGetToolsPath)\NuGet.exe 43 | @(PackageSource) 44 | 45 | "$(NuGetExePath)" 46 | mono --runtime=v4.0.30319 $(NuGetExePath) 47 | 48 | $(TargetDir.Trim('\\')) 49 | 50 | -RequireConsent 51 | -NonInteractive 52 | 53 | 54 | $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(NonInteractiveSwitch) $(RequireConsentSwitch) -solutionDir "$(SolutionDir) " 55 | $(NuGetCommand) pack "$(ProjectPath)" -Properties Configuration=$(Configuration) $(NonInteractiveSwitch) -OutputDirectory "$(PackageOutputDir)" -symbols 56 | 57 | 58 | 59 | RestorePackages; 60 | $(BuildDependsOn); 61 | 62 | 63 | 64 | 65 | $(BuildDependsOn); 66 | BuildPackage; 67 | 68 | 69 | 70 | 71 | 72 | 73 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 88 | 89 | 92 | 93 | 94 | 95 | 97 | 98 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 130 | 131 | 132 | 133 | -------------------------------------------------------------------------------- /BAG.UnityPackage.Console.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2012 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BAG.UnityPackage.Console", "src\BAG.UnityPackage.Console\BAG.UnityPackage.Console.csproj", "{040E4BE7-00E3-4E65-8F1C-AA2C02D7B68B}" 5 | EndProject 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6FBE06AC-66E8-412A-A235-4926D1C39665}" 7 | ProjectSection(SolutionItems) = preProject 8 | readme.md = readme.md 9 | EndProjectSection 10 | EndProject 11 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{E33FF903-FE02-4AD7-B2B5-AC0B1123A5B1}" 12 | ProjectSection(SolutionItems) = preProject 13 | .nuget\NuGet.Config = .nuget\NuGet.Config 14 | .nuget\NuGet.exe = .nuget\NuGet.exe 15 | .nuget\NuGet.targets = .nuget\NuGet.targets 16 | EndProjectSection 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 20 | Debug|Any CPU = Debug|Any CPU 21 | Release|Any CPU = Release|Any CPU 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {040E4BE7-00E3-4E65-8F1C-AA2C02D7B68B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {040E4BE7-00E3-4E65-8F1C-AA2C02D7B68B}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {040E4BE7-00E3-4E65-8F1C-AA2C02D7B68B}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {040E4BE7-00E3-4E65-8F1C-AA2C02D7B68B}.Release|Any CPU.Build.0 = Release|Any CPU 28 | EndGlobalSection 29 | GlobalSection(SolutionProperties) = preSolution 30 | HideSolutionNode = FALSE 31 | EndGlobalSection 32 | EndGlobal 33 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | unity-3d-package-extract 2 | ======================== 3 | 4 | Simple method to extract .unitypackage files, since it seems to blow up unity on occasion and if you have lots of assets there is a good chance you just want to pull in what you need... 5 | 6 | Install with [chocolatey](http://chocolatey.org/) 7 | 8 | cinst upackx 9 | 10 | usage: 11 | 12 | upackx [-i] packageFile.unitypackage [-o] directoryName 13 | extracts packageFile.unitypackage to the folder 'directoryName' -------------------------------------------------------------------------------- /chocolatey/tools/chocolateyInstall.ps1: -------------------------------------------------------------------------------- 1 | $packageName = 'upackx' # arbitrary name for the package, used in messages 2 | $url = 'http://blog.bagearon.com/downloads/upackx/release.zip' # download url 3 | $url64 = $url # 64bit URL here or just use the same as $url 4 | $validExitCodes = @(0) #please insert other valid exit codes here, exit codes for ms http://msdn.microsoft.com/en-us/library/aa368542(VS.85).aspx 5 | # download and unpack a zip file 6 | Install-ChocolateyZipPackage "$packageName" "$url" "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" "$url64" -------------------------------------------------------------------------------- /chocolatey/upackx.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | upackx 5 | upackx 6 | 0.0.0.1 7 | Brad Gearon 8 | Brad Gearon 9 | unity-3d-package-extract : tool to unpack unitypackages 10 | unity-3d-package-extract cmd line: upackx name.unitypackage destination 11 | https://github.com/bradgearon/unity-3d-package-extract 12 | upackx unity3d unitypackage unity-3d-package-extract admin 13 | 14 | https://github.com/bradgearon/unity-3d-package-extract/raw/master/lic.txt 15 | false 16 | 17 | 20 | initial version 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /src/BAG.UnityPackage.Console/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/BAG.UnityPackage.Console/BAG.UnityPackage.Console.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {040E4BE7-00E3-4E65-8F1C-AA2C02D7B68B} 8 | Exe 9 | Properties 10 | BAG.UnityPackage.Cmd 11 | upackx 12 | v4.5 13 | 512 14 | 15 | 16 | ..\..\ 17 | true 18 | 19 | 20 | AnyCPU 21 | true 22 | full 23 | false 24 | bin\Debug\ 25 | DEBUG;TRACE 26 | prompt 27 | 4 28 | false 29 | 30 | 31 | AnyCPU 32 | none 33 | true 34 | bin\Release\ 35 | TRACE 36 | prompt 37 | 4 38 | false 39 | 40 | 41 | 42 | ..\..\packages\PowerArgs.1.5.1.0\lib\net40\PowerArgs.dll 43 | 44 | 45 | ..\..\packages\sharpcompress.0.8.2\lib\net40\SharpCompress.dll 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | PreserveNewest 67 | 68 | 69 | 70 | 71 | 78 | -------------------------------------------------------------------------------- /src/BAG.UnityPackage.Console/Options.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using PowerArgs; 7 | 8 | namespace BAG.UnityPackage.Cmd 9 | { 10 | [TabCompletion] 11 | [ArgExample("upackx [-i] packageFile.unitypackage [-o] directoryName", "extracts packageFile.unitypackage to the folder 'directoryName'")] 12 | public class Options 13 | { 14 | [ArgPosition(0), ArgRequired(PromptIfMissing = true), ArgExistingFile(), ArgShortcut("i")] 15 | [ArgDescription("Input file, the file to extract")] 16 | public string In { get; set; } 17 | 18 | [ArgPosition(1), ArgShortcut("o")] 19 | [ArgDescription("Output path, defaults to the current path and name of the input file")] 20 | public string Out { get; set; } 21 | 22 | [ArgShortcut("f")] 23 | [ArgDescription("force, true to overwrite existing files")] 24 | public bool Force { get; set; } 25 | 26 | [ArgShortcut("d")] 27 | [ArgDescription("debug, true to launch debugger")] 28 | public bool Debug { get; set; } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/BAG.UnityPackage.Console/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using PowerArgs; 7 | using SharpCompress.Archive; 8 | using System.Diagnostics; 9 | using System.IO; 10 | using SharpCompress.Common; 11 | using System.IO.MemoryMappedFiles; 12 | 13 | namespace BAG.UnityPackage.Cmd 14 | { 15 | class Program 16 | { 17 | static void Main(string[] args) 18 | { 19 | try 20 | { 21 | AppDomain.CurrentDomain.DomainUnload += CleanupBeforeExit; 22 | var parsed = Args.Parse(args); 23 | if (parsed.Debug) 24 | { 25 | Debugger.Launch(); 26 | } 27 | var success = new UnityPackageMetadataProvider().Extract(parsed); 28 | if (success) 29 | { 30 | Console.WriteLine(Environment.NewLine + "Successfully extracted"); 31 | } 32 | 33 | } 34 | catch (ArgException ex) 35 | { 36 | Console.ForegroundColor = ConsoleColor.Red; 37 | Console.WriteLine("Invalid cmd line arguments: " + ex.Message + Environment.NewLine); 38 | Console.ResetColor(); 39 | 40 | ArgUsage.GetStyledUsage().Write(); 41 | } 42 | catch (Exception ex) 43 | { 44 | Console.ForegroundColor = ConsoleColor.Red; 45 | Console.WriteLine(Environment.NewLine + "An error occurred while extracting: " + ex.Message + Environment.NewLine); 46 | Console.ResetColor(); 47 | } 48 | Console.ResetColor(); 49 | } 50 | 51 | private static void CleanupBeforeExit(object sender, EventArgs e) 52 | { 53 | Console.ResetColor(); 54 | } 55 | } 56 | 57 | public class UnityPackageMetadataProvider 58 | { 59 | public bool Extract(Options options) 60 | { 61 | var errors = 0; 62 | 63 | if (string.IsNullOrEmpty(options.Out)) 64 | { 65 | options.Out = Path.GetFileNameWithoutExtension(options.In); 66 | } 67 | var archive = ArchiveFactory.Open(options.In); 68 | Func getFirstLine = (entry) => 69 | { 70 | var path = string.Empty; 71 | using (var sr = new StreamReader(entry.OpenEntryStream())) 72 | { 73 | path = sr.ReadLine(); 74 | } 75 | return path; 76 | }; 77 | 78 | if (archive != null) 79 | { 80 | foreach (var volume in archive.Entries) 81 | { 82 | var tempFile = Path.GetTempFileName(); 83 | try 84 | { 85 | using (var tempStream = File.Open(tempFile, FileMode.Open)) 86 | { 87 | 88 | 89 | volume.WriteTo(tempStream); 90 | tempStream.Flush(); 91 | 92 | using (var tempArchive = ArchiveFactory.Open(tempStream)) 93 | { 94 | Dictionary toExtract = null; 95 | 96 | var pathEntries = from entry in tempArchive.Entries.ToArray() 97 | where Path.GetFileName(entry.FilePath).Equals("pathname") 98 | && !entry.IsDirectory 99 | select entry; 100 | 101 | toExtract = pathEntries.ToDictionary( 102 | pathEntry => Path.GetDirectoryName(pathEntry.FilePath), 103 | pathEntry => getFirstLine(pathEntry)); 104 | 105 | var assets = from entry in tempArchive.Entries.ToArray() 106 | where Path.GetFileName(entry.FilePath).Equals("asset") 107 | && !entry.IsDirectory 108 | select new 109 | { 110 | entry = entry, 111 | path = toExtract[Path.GetDirectoryName(entry.FilePath)] 112 | }; 113 | 114 | var fullOut = Path.GetFullPath(options.Out); 115 | Console.WriteLine("\nExtracting to:\n{0}\n", fullOut); 116 | 117 | foreach (var asset in assets) 118 | { 119 | try 120 | { 121 | var destPath = Path.Combine(fullOut, 122 | asset.path.Replace('/', Path.DirectorySeparatorChar)); 123 | 124 | var destDir = Path.GetDirectoryName(destPath); 125 | if (!Directory.Exists(destDir)) 126 | { 127 | Directory.CreateDirectory(destDir); 128 | } 129 | 130 | Console.Write("{0}", asset.path); 131 | 132 | var exOptions = ExtractOptions.None; 133 | if (options.Force) 134 | { 135 | exOptions |= ExtractOptions.Overwrite; 136 | } 137 | 138 | asset.entry.WriteToFile(destPath, exOptions); 139 | 140 | Console.WriteLine("\tOk"); 141 | Console.ResetColor(); 142 | } 143 | catch (Exception ex) 144 | { 145 | errors++; 146 | Console.ForegroundColor = ConsoleColor.Red; 147 | Console.WriteLine(Environment.NewLine + "error occurred while extracting: " + ex.Message + Environment.NewLine); 148 | Console.ResetColor(); 149 | } 150 | } 151 | } 152 | 153 | } 154 | } 155 | finally 156 | { 157 | if (tempFile != null && File.Exists(tempFile)) 158 | { 159 | File.Delete(tempFile); 160 | } 161 | } 162 | 163 | } 164 | 165 | } 166 | 167 | return errors == 0; 168 | 169 | } 170 | 171 | } 172 | 173 | 174 | } 175 | -------------------------------------------------------------------------------- /src/BAG.UnityPackage.Console/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("BAG.UnityPackage.Cmd")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("BAG.UnityPackage.Cmd")] 13 | [assembly: AssemblyCopyright("Copyright © 2013")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("bfd23ed8-5ae1-4e08-8e1f-becd61742a8d")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /src/BAG.UnityPackage.Console/lic.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Brad Gearon 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /src/BAG.UnityPackage.Console/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | --------------------------------------------------------------------------------