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 rhose87 · Nov 08, 2011 at 09:15 AM · wwwyield

yield www javascript

I have to get an array from an URL and i am using yield www. When i run the application in game mode it works but when i run it on the server my data doesn't show.

 function Start(){
     StartCoroutine("getData");
 }

 function getData(){
     var www : WWW = new WWW("adress");
     yield www;
     myHash = eval(www.text);
     //yield WaitForSeconds(1.0); 
 }
 
 function OnMouseDown(){
     gameObject.Find("wallName").guiText.text = myHash[wallName];
 }

I tried without coroutine and the same result : ok in unity, nothing online.

Comment
Add comment · Show 2
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 softrare · Nov 08, 2011 at 09:47 AM 1
Share

I am going to assume that by "application in game mode" you mean your game running in the Unity IDE and by "on the server" you mean the app running as webplayer in the browser.

How does the data not show? How do you output the data? With print (its not in your code)? $$anonymous$$eep in $$anonymous$$d that there is no inbuilt console in webplayer builds.

There is also a concurrency problem when using WWW in a webplayer build. $$anonymous$$ake sure you don't try to catch the "download ready" event (with some kind of loop), because the webplayer than will never fire it and will hang.

avatar image rhose87 · Nov 08, 2011 at 09:53 AM 0
Share

"application in game mode" = in unity "on the server" = online (i build a player for a website ) I use the data retrieved to set some guiText.text.

I edited my code and added the use of the data from www.

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by softrare · Nov 08, 2011 at 09:59 AM

What if you put it like this?

 function getData() {
     var www : WWW = new WWW("adress");
     yield www; 
     myHash = eval(www.text);
     gameObject.Find("wallName").guiText.text = myHash[wallName];
 }

I know that is not what you are trying to do, but does it work?

Comment
Add comment · Show 5 · 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 rhose87 · Nov 08, 2011 at 10:34 AM 0
Share

it doesn't work. doesn't matter what button i press the result is the same. (I have 4 buttons and when i press one i want to get the name of it from www).

 other ideas ?
avatar image softrare · Nov 08, 2011 at 10:56 AM 0
Share

What about

 function getData() {
     var www : WWW = new WWW("adress");
     yield www; 
     gameObject.Find("wallName").guiText.text = www.text;
 }

This is the most basic case. If that does not work, there is something wrong with the connection or the output method I guess.

Also I myself ealier had problems with using WWW in the webplayer and I noticed that it takes longer for the webplayer to receive data, so you maybe would have to wait a longer time before expecting a result to come up (in case the amount of data your transmit is big).

avatar image softrare · Nov 08, 2011 at 11:01 AM 0
Share

I just remembered something else: be sure that the webplayer is hosted on the same server (and same domain) as the target server script. Otherwise the data will indeed not be transmitted due to browser limitations.

avatar image rhose87 · Nov 08, 2011 at 11:03 AM 0
Share

i receive an array of 476 characters. i don't think the amount of data is a problem. i think the WEBPlayer doesn't work very good with yield because if i build a standalone exe it work great.

other ideas ?

avatar image rhose87 · Nov 08, 2011 at 02:52 PM 0
Share

it's something wrong with my filesystem. the file that i want to get information from it's on the same server as the player. i will try other approach and post a result. thanks softrate.

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Load external mp3 File without streaming 1 Answer

Can I use WWW in Start()? 1 Answer

NullReferenceException in nested Coroutine 0 Answers

WWW isDone when lost internet connection, it return true and not wait for internet connection (Andriod) 1 Answer

Another yield and www question 2 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