Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 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 mrwhip · Feb 24, 2020 at 07:12 AM · resourcesassetdatabaseassetbundlesstoragegif

Do Animated GIFs store properly in an Asset Bundle? Or is it just the 1st frame?

I'm building Asset Bundles with the standard way through the Unity Tutorials and it generates the asset bundle file and manifest correctly - though when I reload the animated gifs from the asset bundle it seems that the GIFs are treated like a static texture. Is the whole file stored there? Or does Unity strip the animated frames and only store the 1st frame?

I'm trying to pass this to my decoder plugin to play - but loading GIFs this way as opposed to via URL doesn't work the same. Do asset bundles actually contain the whole file embedded? Is this a problem with Unity not natively recognizing animated GIFs?

Can Asset Bundles store entire files and act like storage? Or only imported types that Unity natively understands?

Does the new Addressable way of doing things help with this at all? Or should my GIF be stored as a Resource if I don't want it accessed via the web?

thanks for any ideas and 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 Bunny83 · Feb 24, 2020 at 09:51 AM

If you just drop your gif as an gif file in Unity, Unity will import that image as a single Texture2D. AssetBundles contain assets in Unity's internal asset format. So no, if you imported the gif as an image in the Unity editor you get a single Texture2D asset.


If you want to ship the gif file "as it is" you can place it in the StreamingAssets folder inside your Assets folder. Files inside that folder are essentially ignored by Unity and shipped as they are. On most target platforms the streaming assets are shipped in a subfolder of your build. Currently the only exception are Android builds where they are packed inside the APK file. Anyways you can use Application.streamingAssetsPath to get the proper path for the target platform. On Android and WebGL you have to use the UnityWebRequest to load an asset from the streaming assets. On other platforms you can use ordinary File io (System.IO.File).


StreamingAssets is a way to include assets just as binary data as it is into your game build. If you want to include such files in assetbundles you have to change the extention to .bytes. This will make unity to interpret the file as a TextAsset (manual). To access the data you can access such assets as TextAsset. The bytes property gives you access to the raw bytes of the file. TextAssets can be included in AssetBundles or directly inside your project. They are just like any other asset, just that Unity doesn't interpret the data in any way.

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 mrwhip · Feb 25, 2020 at 07:39 AM 0
Share

Thank you very much for the run-down - it wasn't clear that just having a GIF in the Assets folder meant Unity only saw it as a single static 1st frame texture - but I was afraid that was the case.

So Strea$$anonymous$$gAssets is great for shipping GIFs with the game. But then your method of rena$$anonymous$$g to .bytes and getting the data as a TextAsset from an internet requested AssetBundle, implies that I'd need to get the binary data of the GIF as a string from TextAsset and then have to have a decoder that can accept a string input for the binary file? Or am I missing something? Because I don't think the GIF decoder plugin I'm using accepts that to its playback. It just accepts a url path or local path for the binary file. Can you please clarify a little about that part of your suggestion in the case I need to provide non-shipped GIFs to my game?

Thanks again so much for your detailed help!! :)

avatar image Bonfire-Boy mrwhip · Feb 25, 2020 at 03:09 PM 1
Share

You could get the bytes from the "Text Asset" and save to file. Then you've got a local path you can give to the plugin.

avatar image Bunny83 mrwhip · Feb 25, 2020 at 05:45 PM 0
Share

As Bonfire said (and as I have already mentioned in my answer) you should use the bytes property which give you access to the raw byte array (`byte[]`). Even it's called a "TextAsset" it's just a raw data asset. They could have named that class this way.


I don't know what gif loader you use, but I guess it there should be a way of feeding it a byte array. If not it should at least support reading from a Stream. You can create a $$anonymous$$emoryStream from your byte array if necessary. This is all just plain C# / .NET.

avatar image mrwhip · Feb 25, 2020 at 07:42 AM 0
Share

I'm using 2019.3.2f1 if that matters. thanks!

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

126 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 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 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 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 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 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 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

Loading subassets at runtime 1 Answer

onDemandResources problems 1 Answer

How do I store game content as a resource 1 Answer

Message error : BuildPipeline.BuildAssetBundle 1 Answer

Serializing a collection of ScriptableObjects to an ASSET file? 1 Answer


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