Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This post has been wikified, any user with enough reputation can edit it.
avatar image
4
Question by d12frosted · Jun 25, 2014 at 02:28 PM · texture2dtexturesresources

Sprites compression question (their size in build)

Hi. Currently I am working on 2D game for iOS and Android and I have faced one problem with sprites.

Let's assume that we have sprite S (2048x2048). It needs to be imported with Max Size = 2048 and Format = Truecolor (because compressed totally breaking image quality - I don't won't to be killed by designer). Final size of uncompressed file is 16MB. After building testing scene with only one sprite S and unpacking final ipa file I found that sprite S is passing to device uncompressed. Now let's assume that I have lots of different sprites with properties similar to sprite S. And when I install this game on device, actual size of application is really huge (s0 + 16 N, where s0 is size in MB of everything except my sprites and N is count of my sprites). I found it really disappointing, because when I was working with cocos2d I could load into device sprite S as compressed png file with size ~2-4 MB. And on runtime, when I need to load it, it's been uncompressed. In this case actual size of application on device is s1 + 4 N in worst case.

The question. Is it possible to ask Unity3d to send compressed images to device? Or maybe there is asset, library that can handle my problem?

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Xtro · Jun 25, 2014 at 04:02 PM 1
Share

Very good question.

avatar image Dee Va · Jun 25, 2014 at 04:05 PM 1
Share

If you want your game to be played on most android devices, you definitely need to use the compression. i know compression mess up with the semi transparent, but you could avoid this with your art style. Like not blending two colors with low hardness, that way the textures loose lot less quality. (this what i do for my game xD)

avatar image d12frosted · Jun 25, 2014 at 05:13 PM 0
Share

@edwar, I can't use compression from import settings, because our sprites have lot's of semi transparent and gradients. After compressing everything looks so messed (even I can notice it, lol). Anyway, thank you for your answer.

art style. Like not blending two colors with low hardness, that way the textures loose lot less quality. (this what i do for my game xD)

Oh, I didn't understand this. What are art styles?

avatar image Dee Va · Jun 26, 2014 at 01:37 AM 1
Share

For example like this! art style 1 is more likely hand drawing with semi transparents and get messed up when i compress it. bur where as, art style 2, they have only solid colors and when i compress them. they give me almost the same result as uncompressed. :)

2 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by Eric5h5 · Jun 29, 2014 at 03:37 PM

You can store textures as .png files in an external folder, and load those via the WWW class at runtime. The downside is that you lose the usual Unity workflow.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image d12frosted · Jun 29, 2014 at 07:14 PM 1
Share

Thank you for your answer. Currently I am using .bytes extension for my images and loading them via

 var binImage = Resources.Load<TextAsset>(imagePathInResourcesFolder);
 myTexture2D.LoadImage(binImage.bytes);

It's good for me because I can easily load images and unload them to free memory usage :)

avatar image Gnejs d12frosted · May 21, 2016 at 04:28 PM 0
Share

This solution helped me save 2/3 of the size of a bunch of shitty jpgs, cheers! :)

avatar image AhmedGalal1987 d12frosted · Aug 26, 2017 at 11:04 AM 0
Share

Could you please explain more how to implement this solution ?

avatar image HungryGames · Dec 10, 2015 at 10:37 PM 0
Share

And how do you build your scenes? I mean you have to sacrifice the unity workflow for that? Just import every texture manually?

avatar image
0

Answer by Flailer · Jun 28, 2014 at 09:22 PM

You can't "decompress" an image. The process sacrifices quality for reduced file size, chucking out bytes in the image, these cannot be reclaimed later unless these bytes and their pattern are stored somewhere else. Cocos2d does not "decompress" and get you back your image quality as this is not possible, Unity will do the a similar thing as regards to memory allocation as Cocos2d.

Loss-less compression is as it says, loss-less in quality whilst reducing image size, which brings about the question as to why you'd want to decompress it in the first place.

To put it simply, find a better way of getting your sprites to look good compressed or take the install size hit. Either way its gonna be 16mb in memory as a full RGBA32 bit image... regardless of what u do.

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Xtro · Jun 29, 2014 at 02:34 PM 2
Share

I think this is kind of wrong. Well, maybe not wrong but missing...

Compression has two types: Lossy and Lossless. Lossless compression can be uncompressed without loosing any pixels. That's very possible but I think Unity doesn't support this compression type.

avatar image d12frosted · Jun 29, 2014 at 07:18 PM 0
Share

What I saw from my experiments is that the Unity sends image assets is raw to device (so 4096x4096 texture in RGBA32 takes as 64 $$anonymous$$B). But I would like to send on device png file that weights much less (~4 $$anonymous$$B). I understand that in run-time this png will be "decompressed" and will take 64 $$anonymous$$B of RA$$anonymous$$, and it will take time. But I'd rather put LOADING screen than publishing game that weights 2.5 GB for mobile phones. And btw, ipa file of such big application weights only 250 $$anonymous$$B. As expected, zipping can compress lossless.

avatar image Flailer · Jun 30, 2014 at 08:05 AM 0
Share

Yes, you are right Xtro, maybe I didn't expand enough, my first paragraph is about lossy compression and the second about lossless and I'm sort of asking why you'd want to uncompress/ mess with a compression format that loses you no pixels.

Secondly, Unity only sends it "raw" or truecolor if you ask it to. At some point this image will have to be compressed if you want the game smaller. You could look into writing your own lossless compression script for Unity?

avatar image d12frosted · Jun 30, 2014 at 08:37 PM 0
Share

Oh, I already found workaround. Look for my comment to Eric5h5's answer. Anyway, thank you for you answer. :)

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

10 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Assigning a texture for object in inspector. Is it loaded right away? 0 Answers

Displaying an image from a resource folder. 2 Answers

How to get a Texture asset that is in the project and pass it to a function? 3 Answers

Does loading a Resource load that resource's dependencies? 1 Answer

Assigning script-generated textures 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges