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 /
avatar image
1
Question by Chris Raadjes · Jul 10, 2013 at 09:57 AM · iphonegraphicsoptimizationtextureformat

How do I store textures as ".PNG" in the final build?

Hey all.

I'm an artist working on a board game for tablet devices. Due to the nature of these games, we have a large amount of unique of painted assets that do not compress well with standard formats. As such, we'd like to use .PNG compression to store our images in the final build, knowing that when they render they will be truecolour size in VRAM.

I've seen some scripts floating about, but no details to incorporate these into an artistic workflow; or how to set up the project so that these scripts become workable. As such, I'm a bit lost on how I can achieve this in our projects.

Any ideas would be greatly appreciated!

Comment
Add comment · Show 5
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 CHPedersen · Jul 10, 2013 at 10:44 AM 1
Share

I'm not sure I totally understand the problem. Can't you just include the textures as PNG in your Assets/Resources folder and load them with Resources.Load in scripts, and then make sure you set their format to truecolor in the texture's import settings in the editor?

When you build your project, Unity packs the PNG file into the installer for the mobile platform, so it is stored as PNG in the final build. The truecolor format will be applied when you load the stored pngs into a Texture2D.

avatar image Chris Raadjes · Jul 10, 2013 at 11:05 AM 0
Share

Hey CH,

Thanks for the quick response! Unfortunately, Unity doesn't allow you to keep textures under your resource folder as .PNG. It will automatically override this setting, and even if you manually assign formats .PNG is not a supported format.

In our experience, if you then build the final app, post-install it will have all textures included in the format you've specified in the editor. This means that they'll be Truecolour in our case, because that's the format we want to use when rendering the textures in our game.

We basically want to $$anonymous$$imize the size of the app after the user has installed it to their mobile device - we've done a quick calculation, and it saves us about 150 megabytes between truecolour textures and PNG textures.

Sorry if I come off as clueless btw - code is not my discipline, so I'm bound to miss basic things. As far as I know, Resources.Load deals with putting textures to objects - but we don't have any issues at the render stage. It's purely storage that's our concern!

avatar image CHPedersen · Jul 10, 2013 at 11:12 AM 0
Share

Hey Chris,

That's simply not the case - Unity supports PNG and has for ages. Here's a screenshot from my own Resources folder right now:

alt text

You can find the list of supported image formats, including PNG, here: http://unity3d.com/unity/workflow/asset-workflow

It does not work with PNG internally at runtime, of course, since PNG is a compression format for storage on disc. When loaded into memory, the file is decoded into whatever format you choose in the import settings, e.g. Truecolor.

pngfiles.png (101.7 kB)
avatar image Bunny83 · Jul 10, 2013 at 11:27 AM 2
Share

There's a difference between what files Unity can import and how they are stored in a build. Unity will store all assets in it's own asset-format. This doesn't use PNG compression on android. See the Android section on this page:

http://docs.unity3d.com/Documentation/Components/class-Texture2D.html

shaderop showed the only way to enforce PNG compression in an android build

avatar image CHPedersen · Jul 10, 2013 at 11:28 AM 0
Share

Ah, I understand. :) Thanks for clearing that up!

1 Reply

· Add your reply
  • Sort: 
avatar image
3

Answer by shaderop · Jul 10, 2013 at 11:13 AM

If you change the extension of your PNG file to .bytes and then add them to your project, Unity will treat them as binary Text Assets and won't mess with their contents. Then it becomes possible to load them at runtime using Texture2D.LoadImage or similar methods.

Comment
Add comment · Show 2 · 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 Chris Raadjes · Jul 10, 2013 at 11:57 AM 0
Share

Thanks for your help all!

I assume loading them at runtime means we can load all the .bytes files at the start of the game (on say, the loading screen) or does every single .bytes have to be loaded when the texture is actually needed?

avatar image Chris Raadjes · Jul 10, 2013 at 12:13 PM 0
Share

Thanks for your help all!

I assume loading them at runtime means we can load all the .bytes files at the start of the game (on say, the loading screen) or does every single .bytes have to be loaded when the texture is actually needed?

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

18 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Pitfalls for characer/animations on the iPhone 1 Answer

How to support Retina display 1 Answer

How to implement an ammo counter using textured quads? [Scripting doubts] 2 Answers

Swiping images across the screen - iPhone 0 Answers

What is the expected behaviour of Dynamic Batching? 2 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