Hello, i have this very simple game that connects to URL and pulls text from that URL so i can use it in the game.
IEnumerator Start() {
string url = "pastebin.com/raw.php?i=WU98E0Lu";
WWW www = new WWW(url);
yield return www;
text = www.text;
}
This works perfectly inside editor and in desktop deployment.
But when i deploy it for the web, it won’t work. I googled for hours and found out there is this Sandboxing going on for security reasons. And i cant add the file unity wants (crossdomain.xml) to the root of pastebin.com for obvious reasons.
The question is how do i overcome this problem, I have to have easily editable online resource so i can add new text.
Please help, thanks.
Initially you can’t really overcome this problem. This is essentially a protection mechanisms to avoid cross site scripting, so that games like yours, can’t access other websites unless they are under the same domain, or the owner of the website allows you to do this.
However, there is indeed a way to circumvent the problem, which is essentially creating a proxy server or webservice.
Your proxy webservice can simply collect the site that you are looking for, and pass it along to your game. Your server will obviously need to have a crossdomain.xml file, unless it is hosted in the same domain.