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 sarahBS · Sep 14, 2020 at 03:40 PM · texturejpganimated-texture

Getting red question mark for texture animated jpg

Hi!

I'm quite new in Unity.. hope this question will make sense..

I'm getting from server a jpg format url which should be presented as texture. It works well for regular jpg but once the jpg is animated I'm getting a red question mark.

This is the code I'm using:

     public RawImage image;
 
 
 public static IEnumerator GetTexture(string url, object o, Action<Texture, object> callbackSucsses, Action<string> callbackFailed)
     {
         UnityWebRequest request = UnityWebRequestTexture.GetTexture(url);
         yield return request.SendWebRequest();
 
         if (request.isNetworkError || request.isHttpError)
         {
             callbackFailed("");
         }
         else
         {
             Texture myTexture = ((DownloadHandlerTexture)request.downloadHandler).texture;
             callbackSucsses(myTexture, o);
 
         }
     }
 
 // callback sucsses 
  private void setUI(Texture texture, object index)
     {
         int i = (int)index;
 
         image.texture = texture;
     }
 

Function setUI is called even when the texture is presented as a question mark.

Example for animated jpg: animated_jpg_example

What can I do in order to get the animated jpg right? I dont even need the animation, first or middle frame of it will be enough.

Thank you very much, will appreciate any answer / direction :)

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

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Bunny83 · Sep 15, 2020 at 06:12 AM

The JPEG format doesn't support any kind of animations. The image you've linked is actually a GIF image which Unity can not load at all at runtime. Also "textures" do not support any kind of animations either. Textures are just still images in graphics card memory. A similar question has been asked on StackOverflow.


So there are several options to solve your issue. The best solution is to actually open your gif image in a proper image editor and save the image / frame you want as an actual jpg. Renaming the file to "jpg" does not magically turn it into a jpg.


If you really need to load THAT exact file at runtime, you need a gif image loader. There are several larger libraries which you can use in Unity to load all sorts of image formats including GIF files. However most of them are not free. I worked on a GIF loader some years ago and it's actually working with many common gif variants.. However it's still in a "work in progress" state and not "that" user friendly. However it's not that hard to use either. The steps are essentially:

  1. Create a GIFLoader instance

  2. use one of the Load methods to load a GIF file either from file or from a stream.

  3. The "imageData" list of the generated GIFImage contains the actual frames. You can call "DrawTo" on a frame and pass in a Color32[] array. The method will write the frame data to that array.

  4. Once the frame has been written you can create a Unity Texture2d and use SetPixels32 with that color array.

  5. Don't forget to call Apply on the texture. That's it.

  6. In order to actually "play" the animation you have to draw the next frame on top of the same color array.

A lot gif animations use delta compression so an animation frame might not contain the whole image but only those pixels which have been changed. So you often can not randomly pick a frame from the list and draw it. The frame might need the information from the previous frame(s).

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

Answer by sarahBS · Sep 16, 2020 at 01:41 PM

Thank you!

Helped me a lot :)

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

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

apply jpg texture to game object 1 Answer

Texture on instantiated asset bundle sometimes black only on iPhone 0 Answers

Infintely scrolling texture ends?(only scrolls through once) 1 Answer

Texture compression distortion. 1 Answer

Animated texture on quad 3 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