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 Tudor · Aug 24, 2013 at 11:06 AM · texturewwwstreaming

Streaming large texture through WWW or otherwise. (multiple passes)

I am developing an application for the web (flash and/or web player), and need to keep the size of the application to a minimum.

For this project I need a couple of large 4096x4096 png textures. I have to download these from the web at run time.

I have read around here that WWW.texture cannot "stream" a texture (as in, download an interlaced png in multiple passes). You must always yield until the whole image downloads. I need this functionality, otherwise the user will stare at nothing (or a very very low res placeholder) for quite a few seconds until the whole thing is done.

So I am trying to come up with alternatives.

Can anyone tell me how exactly does this WWW functionality work under the hood? It seems very odd to me that we don't have access to the partially downloaded data in this kind of www request.

What exactly does www.data do? Could I read a partial stream of data from there, and encode it to an image/texture and show it to the user?

The only other alternative I can think of, is to load the images in the enclosing HTML page, then use periodic external calls from unity to fetch whatever data has been loaded so far in the <img/>. It feels like I shouldn't have to resort to this.

Comment
Add comment · Show 1
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 Tudor · Aug 27, 2013 at 03:01 PM 0
Share

Is it at all possible to get access to a low level "downloadedBytes" container to fetch partially downloaded data in unity?

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by balloonanimals · Feb 25, 2017 at 05:16 PM

using System; using UnityEngine; using UnityEngine.UI; using System.Collections; using System.Collections.Generic; using UnityEngine.Networking;

[RequireComponent(typeof(UnityEngine.UI.Image))] public class ImageDownloader : MonoBehaviour { UnityEngine.UI.Image _img;

 private Action del_action;
 private UnityWebRequest wr;
 private DownloadHandlerTexture texDl;
 private Texture2D texture;
 private Sprite sprite;

 void Start () {
     
     _img = GetComponent<UnityEngine.UI.Image>();

 }

 void Update () {

     if (Input.GetKeyDown (KeyCode.Space)) {
         Debug.Log ("Started");
         Download ("http://www.doctorsintraining.com/wp-content/uploads/2013/05/Woman-taking-test.jpg");

     }

     if (del_action != null) {
         del_action ();
     }

 }

 public void Download(string url) {

     texture = new Texture2D (2, 2);
     wr = new UnityWebRequest(url);
     texDl = new DownloadHandlerTexture(true);
     wr.downloadHandler = texDl;
     wr.chunkedTransfer = true;

     wr.Send();

     del_action += Downloadupdate;

 }

 private void Downloadupdate()
 {

     if ( wr.downloadProgress > 0.1f ) {


         //texture.LoadRawTextureData (texDl.data);
         texture.LoadImage (texDl.data);
         //texture = texDl.texture;

         if ( sprite == null ) {

             sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero, 1f);
             _img.sprite = sprite;

         }

     }

     if (wr.isDone) {

         del_action -= Downloadupdate;

         texture = texDl.texture;

     }



 }

}

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

16 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

Related Questions

Is WWW.movie supposed to be this slow? 2 Answers

Unity for showing a html stream 0 Answers

WWW Texture Error 302 1 Answer

Coroutine and set (big?) Texture / Sprite gets noticable Lag 0 Answers

Image Displaying Bleached Texture. 0 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