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
2
Question by pblieka · May 09, 2012 at 05:22 PM · spriteatlastoolpacktextures

Sprite Atlas Generation in android build

Alright, so this is my first post on the Unity forums. So excuse my ignorance of any unwritten rules.

I have built an automatic sprite atlas generator, that searches my project for specific scripts and constructs an atlas from them. This all works fairly well, I have even been able to make use of this for my 3D game objects, by setting the UVs accordingly.

However, I am running into a bit of an issue. Its not major but I am trying to clean up my tool for quicker use. Essentially, I use PackTextures to build the texture, convert it to ARGB32 and then into my desired format (be it DXT or PVRTC etc). This however, seems only to work correctly when my build settings are set to PC Standalone, not Android or iOS.

 Texture2D newTexture = new Texture2D(maxSize
             , maxSize
             , format
             , enableMipMapping);

 _TextureRects = newTexture.PackTextures(textures.ToArray()
             , padding
             , maxSize
             , makeNoLongerReadable);

 Texture2D correctedTexture = new Texture2D(newTexture.width
             , newTexture.height
             , TextureFormat.ARGB32
             , enableMipMapping);
 
 correctedTexture.SetPixels(newTexture.GetPixels());
 EditorUtility.CompressTexture(correctedTexture
          , format
          , TextureCompressionQuality.Normal);

The UVs seem to be remapping correctly regardless of platform. It seems to be the generated texture that is causing the issue. As shown below:

alt text

(As seen on PC)

alt text

(As seen on Android)

Any help, would be greatly appreciated. Thanks in advance!

StdAlnCap.png (155.1 kB)
AndroidCap.png (159.1 kB)
Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by sampenguin · May 21, 2013 at 06:37 PM

This looks like a bug that will live forever in Unity 3.x. I've seen it happen with every UI plug-in I've tried that relies on Unity's texture packer.

It seems to happen when your textures' combined width or height is exactly or over the atlas limit you are targeting, but apparently only on mobile build targets. Although I've not seen your exact example have it happen... personally I've only seen this when one of the textures is actually equal or larger than the full extent of the final atlas. For example, if I'm trying to make a 2048x2048 atlas and my largest texture is actually 2048 high or wide, this error happens, even if it is the only texture I'm trying to put in the atlas.

I think there must be some kind of padding math error on this codepath in Unity.

I've found a slightly ugly workaround, if you reduce your offending texture by a couple of pixels to be less than the final atlas boundary, it no longer happens.

Not sure if this will help you or not, but thought I'd share.

Comment
Add comment · 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

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Texture2D.PackTextures() - maximumAtlasSize 1 Answer

Create 1 NGUI atlas , which has more than 1 PNG's 0 Answers

I can't assign my sprite atlas to a material? 1 Answer

Atlas on Mesh rendering issue 1 Answer

loading sprite from atlas in script 4 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