Using Zip Compression with the Unity 3D web player (Windows)

Hello,
I have currently tried two compression libraries for unzipping files(DotNetZip and SharpZipLib), but neither of them seem to work on the webplayer when running in windows. I am unzipping the files to memory, but both zip libraries give me a text encoding/decoding error. I have researched the problem on the web, and the various answers for copying dlls around are not working in the webplayer. All of the other platforms I have tested work just fine(OSX Standalone, Iphone, Android).

Does anyone have any experience working with a zip library in the webplayer?

Thank you,
Dylan

After trying a bunch of suggestions I found on the web, I finally decided to edit the SharpZipLib library myself, and was able to fix the problem. I am posting the steps below:

Steps to fix unzipping errors on the web player(related to text decoding):

  • Download the SharpZipLib source from: ICSharpCode ยท GitHub
  • Open the main project (ICSharpCode.SharpZLib.csproj) under the /src directory in monodevelop
  • Navigate to the file ZipConstants.cs (Under the zip folder)
  • Replace the functions that use System.Text.Encoding.GetEncoding() with Encoding.UTF8.

Example:
replace
Encoding.GetEncoding(defaultCodePage).GetString(da ta, 0, count);
with:
Encoding.UTF8.GetString(data, 0, count);

Compile your new library(it should compile with no errors)
and then drop it in your unity Plugins folder.

So far I have tested this on OSX, Webplayer(windows and OSx), Android and IOS. For this to work correctly you will need to make absolute sure that the zips you are unzipping are encoded in utf8(which i believe is the default).

Hopefully this helps someone out.

-Dylan

Yep this works very well.

Yes Dylan, it was very helpful ! Thanks a lot :smile: ! (and I confirm that zip compression with SharpZipLib work in the editor but not in the webplayer with unity 4 unless you do as Dylan instructed).
Now I can zip several screenshots of my unity application and upload them in a single zip file on a webserver :slight_smile: !