Unity compress?

Droid Productions

[Love of Magic]
Donor
Game Developer
Dec 30, 2017
6,623
16,731
Short answer, no. Unity (because it is a heart a 3D engine) compresses everything to hardware-optimized compressed textures (DXTx, or other platform specific versions). And that requires the dev to do something, it's not something you can easily mod, like with RenPy.


Slightly longer answer? Possibly. There's set up. As Love of Magic creeps over 1GB, that's starting to look tempting. The problem is that it's not a plug-and-play solution, apart from the work needed to be done in terms of compressing the textures I also need to change all the references , and re-route the loading code to load and decompress the image, then create the sprite. It's doable, just a bit of a bug-magnet. It also breaks unity's basic workflow, which assumes all images are loaded from whatever surface, and stored at build-time as hardware compressed. A better solution would be for Unity to be aware that some resources are disc-space sensitive, and provide that option at the asset setting level. But I don't manage that part of the process.
 

Winterfire

Forum Fanatic
Respected User
Game Developer
Sep 27, 2018
4,955
7,272
Yes, it is possible but only by the developer.

Audio, Textures and so on are imported with default settings, but more often than not, the default settings are not the right ones. It is only a matter of settings really (aside from things like meshes), the source file unlike Ren'Py will not matter... So compressing a PNG texture before importing it to Unity will do nothing.

Last but not least, Unity games drop in size quite a lot when archiving them... Which is pretty good.
 

polywog

Forum Fanatic
May 19, 2017
4,062
6,260
Some of my old concept art and 3D renders from yesteryear are still on display at NASA. Millions of people have enjoyed various works that I have done, but you can't let it go to your head. You want your game to be good, but you also want people to be able to play it. Good doesn't have to be rendered at 8k. If you do, thank you, I appreciate that, but your average player in the world isn't going to download that. Devs should consider making a second copy of their games at a lower res.
 

Winterfire

Forum Fanatic
Respected User
Game Developer
Sep 27, 2018
4,955
7,272
Some of my old concept art and 3D renders from yesteryear are still on display at NASA. Millions of people have enjoyed various works that I have done, but you can't let it go to your head. You want your game to be good, but you also want people to be able to play it. Good doesn't have to be rendered at 8k. If you do, thank you, I appreciate that, but your average player in the world isn't going to download that. Devs should consider making a second copy of their games at a lower res.
Unity does not need a second copy, you can use high res assets and then make various settings to lower the resolution directly from Unity.
Speaking of images, can you put one so I can better understand your message?
 

polywog

Forum Fanatic
May 19, 2017
4,062
6,260
Unity does not need a second copy, you can use high res assets and then make various settings to lower the resolution directly from Unity.
Speaking of images, can you put one so I can better understand your message?
True, Unity will run on the widest range of hardware including consoles... but
Fewer people are going to download a 6GB game.

2wVeKli.jpg

Steam users...
 
  • Like
Reactions: Winterfire

Darksshades

Member
Feb 7, 2020
127
407
Nope. Sorry
Short answer, no. Unity (because it is a heart a 3D engine) compresses everything to hardware-optimized compressed textures (DXTx, or other platform specific versions). And that requires the dev to do something, it's not something you can easily mod, like with RenPy.
I know this is kinda old but I thought I might share what I learned when trying to compress unity games.

There are some unity games that are 100MB inside a .rar and turns into 2GB after extraction. My main focus is was to reduce the size of those game cases.
After extracting the files the reason for that size difference is basically as stated above. All image files and audio files are not compressed at all making a single music 40MB and a big image 7MB while the game might have almost a thousand of those.

I did not have any luck puting the audio files back onto unity but I had some mild success in putting the compressed image files.

There were 2 ways that I found it possible to do that. Here are them:

The first way was using "Unity assets bundle extractor"....
This tool can extract texture files as .png or .tga files but even if you compress the .png when you insert them back it'll turn back to the uncompressed size to go with unitys texture format.

But if you click a single Texture2D and use the Plugins->Edit... you can change the Texture format and the tool will compress it properly.
You don't get any options but you get a fair choice of types. Just changing the texture from ARGB32 to DXT1Crunched(slow!) for example made the image 50% smaller.

This was just a test to see if it was at all possible.
I could not find any way to batch convert the textures and when saving the file back the new image are put together with the resources.assets instead of the resources.assets.resS file.
So you'd need to convert all the textures2D and them delete the now unused resources.assets.resS(which only had the texture files).
Audio clips are stored on sharedassets0.assets.resS.

The other more proper way:

Using UnityEX you can extract all Unity's Texture2D as .tex files and reimport them back.
So if you could convert the .tex files to a proper more compressed format and reinsert them back it should work.
I could not test that as I had no idea and could not find an easy-to-use tool to convert textues .tex format.

Disclaimer Notes:
Reinserting AudioClips back into unity is way too complicated so I give up on that.
I don't know anything about compression and only tried to use the already made tools to solve this problem so I might be wrong.
 
  • Like
Reactions: ro11 and bas

lewdgamerxxx

Active Member
Game Compressor
Sep 6, 2018
723
2,071
Joey the helper in BFL:AR
No, there is no easy way to losslessly compress unity games without the source code. But you can repack them. This will not reduce the original size but it'll highly compress the the game to make sharing easier. Look at my signature for more info.
 

Winterfire

Forum Fanatic
Respected User
Game Developer
Sep 27, 2018
4,955
7,272
You guys are just wasting your time: As I have mentioned before, I can use a 300mb psd file as texture and it will be built according to the compression settings, the source file does not matter... Unlike Ren'Py.

Repack is possible, but considering how much space you save by simply zipping the game, it is hardly worth the time and effort.
Of course there are some exceptions: There is an unity VN whose name I cannot remember that is 15gb, that game could really use a repack, but it is the developer's fault for not properly using the engine.
 

Winterfire

Forum Fanatic
Respected User
Game Developer
Sep 27, 2018
4,955
7,272
It is though.
Look, Unity is much different than Ren'Py. Compression works much differently than what you may think, and it is not always build size.

Ren'Py simply reads they file as they are, and they are not packed, which means you can easily corrupt compress them with third party tools.

In Unity I can have a 500mb psd file for a character and when I build the game, that 500mb will transform into a 2mb (Depends on settings, resolution, and so on) image during the build process.

Unity has already built-in methods to compress resources, and it is not always about reducing the game size... Sometimes, it is more preferable to have a +200% import size in order to be easier on the CPU, you can read more about it here if you are curious:

Not to mention that when you zip your unity game, the size is greatly reduced for distribution.


TLDR; Unity Engine already handles compression, you do not need to worry about it. It is not Ren'Py.
 
  • Sad
Reactions: Shubhanshu Chauhan