Unity 5.2.2 webgl bundle loading failing
Hello there,
My problem is simple : bundle loading through the WWW class return "unknown error." on a webgl export
using UnityEngine;
using System.Collections;
public class LoadingWww : MonoBehaviour {
string content = "";
IEnumerator Start(){
content = "[LOADING INFO]";
WWW www = new WWW("http://www.website.com/path/to/bundles/text");
if (!www.isDone) yield return www;
if (www.error != null)
{
Debug.Log("Failure : " + www.error);
content += "\nfailure : "+www.error;
}
else
{
Debug.Log("Success !");
content += "\nSuccess !";
}
}
void OnGUI(){
GUI.Label(new Rect(0,0,Screen.width, Screen.height), content);
}
}
Here "text" in the url is a bundle filled with .txt files
Works fine in the editor. Just doesn't work on a webgl export.
www.error log : "Unknown error."
Any ideas ?
Thanks for the help !
==EDIT==
It seems that the issue is linked to the distant domain having a CORS properly set. ( http://docs.unity3d.com/Manual/webgl-networking.html )
But I have no idea how to do that.
Answer by ABerlemont · Nov 12, 2015 at 01:28 PM
So, the answer for my issue was something about security with crossdomain transaction ( http://docs.unity3d.com/Manual/webgl-networking.html )
Just add this in a .htaccess file at root level of the target domain
Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Headers "origin, x-requested-with, content-type"
Header add Access-Control-Allow-Methods "PUT, GET, POST, DELETE, OPTIONS"
I have tried putting the .htaccess file in the root level of target domain but still get the "$$anonymous$$ Error" is there any other issue for assetbundles in WebGL
Your answer
Follow this Question
Related Questions
WebGL Memory Error when loading asset bundle 0 Answers
Encapsulating scenes in Adressables to reduce loading times in Web GL 0 Answers
the latest version of unity physics? 0 Answers
Why does my toon shader not work when I build it in webgl? 0 Answers
How to capture Camera disconnect in using Webcamtexture for Webgl 1 Answer