Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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
2
Question by Metalbob · Aug 17, 2015 at 10:39 PM · webglwww class

Why WWW class is not working with WebGL

Hello,

I'm having some trouble with the WWW class:

 WWW test = new WWW("http://localhost:8888/StreamingAssets/Scenario/ScenarioTest.snr");

 while (!test.isDone)
     Debug.Log(test.bytesDownloaded);

 scenario.LoadFromString(test.text);

When I run this part of code in the Editor, it perfectly works, but in the WebGL exports, test.bytesDownloaded doesn't increase and test.isDone is never true.

In the .htaccess file I've got this:

 Options +FollowSymLinks
 RewriteEngine on
 
 RewriteCond %{HTTP:Accept-encoding} gzip
 RewriteRule (.*)Release(.*)\.js $1Compressed$2\.jsgz [L]
 RewriteRule (.*)Release(.*)\.data $1Compressed$2\.datagz [L]
 RewriteRule (.*)Release(.*)\.mem $1Compressed$2\.memgz [L]
 RewriteRule (.*)Release(.*)\.unity3d $1Compressed$2\.unity3dgz [L]
 AddEncoding gzip .jsgz
 AddEncoding gzip .datagz
 AddEncoding gzip .memgz
 AddEncoding gzip .unity3dgz
 
 Header set Access-Control-Allow-Credentials "true"
 Header set Access-Control-Allow-Headers "Accept, X-Access-Token, X-Application-Name, X-Request-Sent-Time"
 Header set Access-Control-Allow-Methods "GET, POST, OPTIONS"
 Header set Access-Control-Allow-Origin "*"
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 Inaetaru · Aug 23, 2015 at 06:22 PM 0
Share

I'm not sure whether it's really the issue, but I think the problem lies in while (!test.isDone). WebGL is currently not multi-threaded. If (this is my hypothesis) WWW class is actually downloading the data in separate thread in Editor, you can wait with while (!test.isDone) and then get the result in the Editor or Standalone. In that case, however, implementation of WWW class in WebGL must be different - the downloading must be done in main thread - that means that Unity engine waits until you finish your update and then the downloading is done/continued. But with while (!test.isDone) you never finish your update, so download method is never called so the downloading never finish, too. That's why yield return www; works. I guess.

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by ZeoWorks · Aug 22, 2015 at 11:40 PM

It seems everyone is having IEnumerator issues in webGL, particularly with firefox. Unfortunately there currently is no known fix.

Comment
Add comment · Show 1 · 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 Metalbob · Aug 23, 2015 at 05:20 PM 0
Share

Ok, it seems it's working with a coroutine which takes the WWW object as parameter:

     private IEnumerator $$anonymous$$yCoroutine(WWW www)
     {
         yield return www;
 
         if (null != www.error)
             Debug.Log("WWW Error: " + www.error);
     }

Thanks anyway ^^

avatar image
0

Answer by Dipa · Apr 10, 2019 at 12:45 PM

Hello @Metalbob, working with a coroutine which takes the WWW object as parameter: is it working for you or not?

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

File Paths to load files with WWW for WebGL 0 Answers

Is there a way to load resources with unkown case (.png/.PNG) using www objects? 1 Answer

How can I get a string to work as the key to a dictionary filled with the text of a www object? 0 Answers

How can I access an external folder in the WebGL build of my app? 1 Answer

How to stream a image or text in webGL? 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