Hi all,
I have a unity application and i converted it into web player.
I am trying to use the below code to get a text file and read its data but for some reason or another it seams that the text file is neither not being found or else unity is not getting the data from the text file.
string url = (Application.dataPath + @“/Story/love_Parsed”).ToString();
WWW www = new WWW(url);
string text;
while(!www.isDone)
text = “Loading…”;
text = www.text;
string[ ] wd = text.Split(’ ');
foreach(string w in wd)
{
words.Add(w);
}
On GUI i printed the path (Application.dataPath + @“/Story/love_Parsed”).ToString() to check what the path is and it was “localhost:56726/Story/love_Parsed”. i typed that path in my browser’s url and a file was downloaded on my pc with the data that i wanted.
This means that the path is correct but i dont know why unity is not reading data from that text file.
Can anyone help me and tell me what i should do pls?
hope i was clear enough to tell explain my problem.
if anyone need more information, just tell me.
thanks in advance and thank you for your time
clive
Two things. One is that you need to pre-pend a protocol. If the file is on your local hard disk then file:// is the protocol you want. Also - it’s probably a good idea to include a file extension.
hi,
no luck.
i debugged unity to see what the problem might be and i got SecurityException: No valid crossdomain policy available to allow access.
i searched for the error, found that i have to create an xml file in my root folder of the website, and created the xml.
i re-debugged unity but i was shown the same error again.
can anyone give me tips what im doing wrong pls?
thanks
clive
Hi, try checking your unity project settings. Edit>Project Settings>Editor. Now add the url of the location where the ‘tobeloaded’ file should be. otherwise i recommend an if check what kind of executable your game currently is…if(Application.isWebplayer) then prepend the “file://”.
Cheers
Hi,
i have solved that problem. the problem was that the xml file was not in ASCII format.
but why one problem leads to another.
Im saying this because as soon as i solved that problem, another arises which is unity is all the time crashing,
any reasons why?
thanks
clive