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 THEpancakes · Aug 31, 2012 at 04:24 PM · textwwwhighscore

Problem with WWW

Hi everyone,

I am making a highscore board for my game, it uses a PHP script and a MySQL database. I have all the server side scripts working, but I'm having a bit of a problem retrieving the highscores with Unity and posting them to the game...

Here is the code I am using:

 var targetGuiText : GUIText;
 var myText : String;
 var url = "https://yadayada.com/highscores.php";
 
 function Start() {
 var hs_get : WWW = new WWW (url);
 yield hs_get;
 myText = hs_get.text;
 targetGuiText.text = myText;
 }

This code doesn't work... Whenever I run the game I get the error "text is not a member of the Unity class WWW".

What am I doing wrong?

Comment
Add comment
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

1 Reply

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

Answer by Bunny83 · Sep 01, 2012 at 03:14 AM

What do you mean by "does not work"? The script works perfectly, however i guess you want to display the returned text in your GUIText component... You just store the returned text in a local variable but you don't assign it to the guiText component.

 function Start()
 {
     var hs_get : WWW = new WWW (url);
     yield hs_get;
     targetGuiText.text = hs_get.text;
 }

This works perfectly for me (with a meaningful uri of course since yours doesn't respond at all. Was it just an example? If not are you sure the uri is correct? Keep in mind that most webservers are case sensitive, so http://example.com/test.php is not the same as http://example.com/Test.php or http://example.com/test.PHP)

You should explain your problem clearly and detailed. "Not working" can be anything...

Some possible "not workings":

  • Does not compile do Unity won't even run your game

  • The game crashes when you use the above code

  • It's not doing what you would expect, in this case it would help to know what you would like expect.

So please be more specific.

Comment
Add comment · Show 2 · 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 THEpancakes · Sep 01, 2012 at 03:26 PM 0
Share

Sorry about the misunderstanding, I've edited the post with extra details on what doesn't work.

Your version of the code doesn't work either, I still get the error "text is not a member of the Unity class WWW"... Perhaps it is just my version of Unity?...

avatar image Bunny83 · Sep 02, 2012 at 02:07 AM 0
Share

Well this error is usually caused by one of your classes which is also named WWW. $$anonymous$$ake sure you don't have any file named "WWW.js" in your project. It will hide the WWW class that is inside the UnityEngine namespace. If you're not sure where that file is, you can quick test it by replacing "WWW" in your script above with "UnityEngine.WWW". This will force the compiler to use the WWW class from the UnityEngine namespace.

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

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

HighScore Names 1 Answer

WWW.url ERROR:This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript support 2 Answers

WWW. Print gives a 'Message Truncated' 1 Answer

JsonUtility deserialization via JSON file doesn't work on WWW, works on File.ReadAllText 1 Answer

[Solved]WWW function issue on build. 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