• 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 Excelerator · Feb 25, 2015 at 11:30 PM · textfiledownloadread

Trying to download and show contents of text file

Something that seems so simple, yet all the console shows is a bunch of question marks when I use this code. All I want to do is be able to read a small string and check if there is a new download available for the game. Then, I can tell the player "Hey there is a new version available. Want to download it?" Then I can direct them to a link or something.

 var url = "http://www.mackenziemelby.com/download/i/mark_dl/u/4011917382/4618859823/sync_ExplosiveDrive.txt";//?dl=1
 var www : WWW;
 
 function Start(){
    www= new WWW(url);
    yield www;
    Debug.Log (www.text);
 }
 
 function Update(){
 if(www.progress<1)
 print ("loading"+www.progress);
 
 }
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 Excelerator · Feb 25, 2015 at 11:54 PM 0
Share

checked www.error no errors. Seems to download just fine. It's just www.data and www.text both return "����" as a string.

avatar image tigertrussell · Feb 26, 2015 at 12:20 AM 0
Share

You try to print the text in your Start() function but it looks like the Update() function is accounting for a case where it hasn't been downloaded, yet. $$anonymous$$aybe you should be putting your Debug.Log(www.text); call in an else statement after your if(www.progress<1)?

1 Reply

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

Answer by tigertrussell · Feb 26, 2015 at 12:21 AM

From my comment, try this:

  var url = "http://www.mackenziemelby.com/download/i/mark_dl/u/4011917382/4618859823/sync_ExplosiveDrive.txt";//?dl=1
  var www : WWW;

  var spamLimiter = false;
  
  function Start() {
     www= new WWW(url);
     yield www;
 //    Debug.Log (www.text);
  }
  
  function Update() {
     if(www.progress<1) {
        print ("loading"+www.progress);
     }
     else if(!spamLimiter) {
        Debug.Log(www.text);
        spamLimiter = true;
     }
  }

Comment
Add comment · Show 3 · 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 Excelerator · Feb 26, 2015 at 02:07 AM 0
Share

Still giving me the question boxes in the console: "����" No idea what that means or why it's appearing.. The actual txt file I am referencing should just print out "Testing stuff".

avatar image Excelerator · Feb 26, 2015 at 03:24 AM 1
Share

Oh! I finally figured out what was going on. It's a bug (or feachur) in Unity. If you look at "var url" which is a public variable, is shows the right address in the code, but for some reason, an old address was stuck in the inspector. Yeah.. all because the code doesn't override the inspector like it did in the old versions of unity. Huh.. problem solved.

avatar image AuggoDoggo · Sep 09, 2016 at 04:22 AM 0
Share

Wow... I had the exact same problem, I had my url string set to public and it was filled in to an image in the editor.

I don't think some people realize how helpful it is when they come back and post how they eventually solved ridiculous things like this, so I am commenting to let you know your comment saved me a decent amount of head-banging-against-wall.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

21 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

Related Questions

How to read particular line from *.txt file? 1 Answer

Confused about intermediate string reading. 1 Answer

How do I read read from and write to a text file? 2 Answers

Write and read text files with c# 1 Answer

Why is reading some text files with JS so darn slow?! (title changed to reflect answers) 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