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 /
  • Help Room /
avatar image
0
Question by paddywwoof · Dec 14, 2017 at 09:56 PM · scripting problemurldownloading

is there a trick to getting www to work

I'm using 2017.2.0f3 personal on linux and can't get urlrequest to work. I've tried everything I've been able to find searching the internet but can't get it to work. Is there some really obvious thing that everyone else knows but I don't?

The script should get a value from a local server but to attempt to eliminate possible errors I put a page on line with just a number on it and change the url to that. (you can check that that works in a browser). However the threaded function never gets past the yield line.

 public class follower : MonoBehaviour {
     ...
     public string URL = "https://www.eldwick.org.uk/files/val.txt";
     ...
     void Update () {
         if ((Time.time > last_speed_tm + DT) && !url_queried) {
             StartCoroutine(WaitForRequest());
         }
         ...
     IEnumerator WaitForRequest() {
         print("got here");
         url_queried = true;
         WWW www = new WWW(URL);
         print("then here");
         yield return www;
         print("but never here");
         speed = float.Parse(www.text);
         print("speed " + speed);
         last_speed_tm = Time.time;
         url_queried = false;
     }
 }

I'd be grateful for any pointers.

Paddy

PS amongst the many things I've tried was the following commented out version of the coroutine method

     /*url_queried = true;
     using (UnityWebRequest www = UnityWebRequest.Get (URL)) {
         print ("got here");
         yield return www.Send ();
         print ("but not here");
         if (www.isNetworkError || www.isHttpError) {
             print ("oops " + www.error);
         } else {
             speed = float.Parse(www.downloadHandler.text);
             print("speed " + speed);
         }
     }
     url_queried = false;
     last_speed_tm = Time.time;
 }*/

Comment
Add comment · Show 7
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 kaplica · Dec 14, 2017 at 09:59 PM 0
Share

WWW class is being depreciated. Use new UnityWebRequest

avatar image paddywwoof kaplica · Dec 14, 2017 at 10:06 PM 0
Share

Yes, at one stage I thought I was onto something, but didn't seem to make any difference!

avatar image kaplica paddywwoof · Dec 14, 2017 at 10:19 PM 0
Share

It works fine on my end, except I didn't use your Update method.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by paddywwoof · Dec 15, 2017 at 12:16 PM

Aaaaarg. Just noticed the VERY annoying feature of Unity that public variables are set in the Editor Inspector panel so my changes to the URL in my script were being overwritten by the old (wrong) values. I have now gone through my scripts and changed all the

public float x = 0.0;

to

public float x;

what a waste of time.

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 kaplica · Dec 15, 2017 at 09:16 PM 0
Share

I would advise to start debugging your code... Visual Studio integrates quite nicely with Unity and offers good debugging tools. If you were doing this you would notice immedietaly :)

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

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

Related Questions

how can I open url link in Unity/Vuforia android app 2 Answers

C# - Cannnot access variable in another script unless I get the component everytime. 1 Answer

Any easy way to choose the method called when clicking a button? 0 Answers

What is the new SceneManagement equivalent for Application.Quit? 1 Answer

Is it possible to use the job system to modify UI elements like text? If so, how? 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