Why is the below code failing? I am trying to open a text file in the webplayer.
string url = Application.dataPath + @“/Move.txt”;
WWW request = new WWW (url);
while ( !request.isDone) {
Debug.Log( “Loading…”);
}
Debug.Log ("Data: " + request.data);
Console Error:
You are trying to load data from a www stream which had the following error when downloading.
Could not resolve host: E; Host not found
[ code][ /code] tags when pasting in code into the forums please, helps with formatting/readability. There is a sticky about them in the scripting section.
I’m a little confused as to where the file is. Application.dataPath would suggest it’s within the app/resources folder, but you are trying to use the WWW functions which streams content from other servers/sites
if you just want to load a text file from the Assets/Resources/ folder in your app you can just use:
TextAsset myFile = (TextAsset)Resources.Load("TextDoc.txt");
I am using WWW request to load the file as it is a web build For testing in editor mode the file is in Asset directory in editor mode. I think I will have to keep the txt file in the same directory as .3d file in web hosting. Hope it clarifies your questions.