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 Chaosgod_Esper · Mar 24, 2014 at 04:20 PM · texturewwwloadingwww.textureprogress

Texture loading via www.texture not loading!

Hi there,

i tried to load a image via WWW. therefor i created a IEnumerator and started loading with WWW(url).

to show loading progress, i created a progressbar with NGUI, and set a while loop in the ienum. this includes the setting of the progressbar to www.progress, and a yield that waits for the end of the frame.

problem... the www.progress always seems to be 0.0... so the image isn't loading :/ It´s working for my Audio Listener...

any ideas what can cause this problem?

The Code:

     private WWW www;
 
 [...]
 
     void OnClick() {
         Debug.Log("Button geklickt!");
         //LADE AUDIOPLAYER
         if(Buttonsprite.spriteName == "Image_Audiofile"){
             Debug.Log("Button ist Audiobutton!");
             StartCoroutine(GetAudiofile());
         }
         else if(Buttonsprite.spriteName == "Image_Imagefile"){
             Debug.Log("Button ist Imagebutton!");
             StartCoroutine(GetImagefile());
         }
     }
 
 [...]
 
     private string urlstring, cutstring;
     private string[] urlarray;
     IEnumerator GetImagefile(){
         Viewer_Image.SetActive(true);
         Viewer_Main.SetActive(false);
         urlstring = ContentHolder.contents[(int)Ownfields.Arrayfield.x, (int)Ownfields.Arrayfield.y].cont_linkurl;
         www = new WWW(urlstring);
         if(www.error != null){
             Debug.Log("Image WWW ERROR: " + www.error);
         }
         while(www.progress < 1){
             Viewer_Image.transform.Find("StreamingBar").GetComponent<UISlider>().value = www.progress;
             Viewer_Image.transform.Find("Ladestand").GetComponent<UILabel>().text = "Ladestand: " + ((int)(www.progress * 100.0f)).ToString() + "%";
             Debug.Log(www.progress);
             yield return new WaitForEndOfFrame();
         }
         Viewer_Image.transform.Find("StreamingBar").GetComponent<UISlider>().value = 1.0f;
         Viewer_Image.transform.Find("Ladestand").GetComponent<UILabel>().text = "Ladestand: 100%";
         ImagePlane.renderer.material.mainTexture = new Texture2D(www.texture.width,www.texture.height);
         www.LoadImageIntoTexture((Texture2D)ImagePlane.renderer.material.mainTexture);
         ImagePlane.transform.localScale = new Vector3(www.texture.width, www.texture.height, 1);
         ImagePlane.SetActive(true);
 
     }
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 Chaosgod_Esper · Mar 31, 2014 at 08:29 PM 0
Share

anyone has an idea? :(

2 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by scottharber · Oct 11, 2014 at 10:40 PM

I had a similar problem and just solved it.

The trick is to save your textures as PNG before you download them using WWW. Jpg doesn't download through iOS for some reason.

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 Andre Barbosa · Mar 24, 2014 at 04:40 PM

You should store the WWW var as a global var and update the progress bar on the Update() function. Something like the following:

 private WWW www;
 private int progress;
 
 public string host;
 public string uriVersion;
     
 IEnumerator GetWWW () {
     using(www = new WWW("http://" + host + "" + uriVersion)){
             
         yield return www;
             
         if (www.error != null){
             Debug.Log("WWW download had an error:" + www.error);
         }
         else{
             //Do whatever you want with the www var
         }
     }
 }
 
 // Use this for initialization
 void Start () {
     StartCoroutine(GetWWW());
 }
     
 void Update () {
     //Store the progress as an integer value
     progress = Mathf.RoundToInt(www.progress * 100f);
 }
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 Chaosgod_Esper · Mar 24, 2014 at 04:45 PM 0
Share

i pasted my code in the start post.. so you can see what i´ve done.

avatar image Andre Barbosa · Mar 24, 2014 at 04:56 PM 0
Share

On your GetImagefile() function, www.progress is always going to be either 0 or 1.

You should check the www.progress on Update().

Your GetImagefile() function should be something like:

 IEnumerator GetImagefile(){
 
     using(www = new WWW(www = new WWW(urlstring)){
 
          yield return www;
  
          if(www.error != null){
              Debug.Log("Image WWW ERROR: " + www.error);
          }
          else{
 
              //Load Image
              www.LoadImageIntoTexture((Texture2D)ImagePlane.renderer.material.mainTexture);
          }
     }
 }
 
 void Update(){
      Viewer_Image.transform.Find("Strea$$anonymous$$gBar").GetComponent<UISlider>().value = www.progress;
      Viewer_Image.transform.Find("Ladestand").GetComponent<UILabel>().text = "Ladestand: " + ((int)(www.progress * 100.0f)).ToString() + "%";
 }

I haven't tested this (Some of it is your code really), but it should get you started

avatar image Chaosgod_Esper · Mar 24, 2014 at 05:22 PM 0
Share

Same thing.. The image isn´t loading.. www.progress is always 0.000000f And so, the progress bar is always on a value of 0, and the Label is always showing "0%"

avatar image Chaosgod_Esper · Mar 27, 2014 at 08:27 PM 0
Share

Any idea? It doesn´t matter if i use a update method or the while loop.. www2.progress always is 0

Interesting at this problem: $$anonymous$$y Audio-Player works the same way. With a while loop and the UISLider/UILabel.. And it´s working!!!!

Why not the image loader?

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

23 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

Related Questions

Host Image/Texture using Unity server, then request it using WWW on client 0 Answers

Image is not loading into Texture 0 Answers

Large memory footprint increase when assigning a GUITexture from a WWW Object on iPad 1 Answer

Image Displaying Bleached Texture. 0 Answers

Problem while loading an image from url 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