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
0
Question by tmsduman · Jun 25, 2015 at 12:59 PM · assetbundletexture2dsprite packer

Create an asset bundle from Sprite Packer Texture

Hi everybody,

i put some sprite in a folder and tag them by script. After that i call the Packer to rebuild atlases. Thats working fine. Now i want to store the resulting atlas texture in an asset bundle but this is not possible. I can access the Texture2D of the atlas but this not readable so i can't copy it to a new Texture2D to store it. Also it is not possible to create a new asset from the texture because it is already an asset. Also i can't access the TextureImporter of the texture because the asset path is an empty string.

Does anybody know how i can access the texture of the sprite packer and put it in an asset bundle so i am able to reload it from web? Or does anybody know how to open the cache and extract the texture so i can store it in another folder?

Thanks for help

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
1
Best Answer

Answer by tmsduman · Jul 07, 2015 at 12:11 PM

If anybody is needing this later: i finally found a working solution. After i imported the sprites and repacked the sprite packer i do the following things: - Create a new Texture2D with the same height and width like the atlas texture you got with Packer.GetTexturesForAtlas(atlasName) - Set all Pixels of the new texture to be transparent - iterate to all imported sprites and get their UVs with SpriteUtility.GetSpriteUVs(sprite, true) and save the position rect of the sprite on the atlas and store it to SpriteMetaData - also make sprite readable and read all pixels of it and set them to the new texture at the previous gotten position - apply new texture and save it with File.WriteAllBytes and EncodeToPNG - refresh assetdatabase - get texture importer of the new texture and mark it as multiple sprite and set the SpriteMetaDatas array to spritesheet - finally set assetbundle name and reimport the asset

Hope this helps you. I anyone needs the code, contact me.

Comment
Add comment · Show 3 · 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 WiedemannD · Jul 21, 2015 at 03:23 PM 0
Share

This sounds like quite a heavy workaround. It was said that Unity 5.2 had a fix for this (http://forum.unity3d.com/threads/working-multi-resolution-sprite-sheets.274683/page-2). I'm hoping a patch release with the fix will come a bit earlier, but would you $$anonymous$$d maybe posting your script/code? It sounds like a huge amount of work and would be really helpful for the time till 5.2 :)

avatar image WiedemannD · Jul 24, 2015 at 08:09 AM 0
Share

Unity's patch release 5.1.2p1 seems to solve this issue!

Though getting a look in your solution would still be pretty great, as some third party plugins are not compatible to Unity's sprite packer, but it would still be awesome to use its functionality and then "exporting" the atlases to common image files, like you did. :)

avatar image Pratap-Dafedar · Dec 14, 2015 at 02:43 PM 0
Share

Hello tmsduman, Would you be so kind to help me with your sample code, If that can help me with accessing the atlas from sprite packer. Thank you in advance.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Sprite in Asset Bundles returned a Texture2D 3 Answers

Managing your sprites in a project question. 0 Answers

Load Unity 4.3 Sprites with AssetBundles 5 Answers

Smooth Synchronized HD Video Playback 0 Answers

AssetBundle.Load() to Texture2D 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