Page 1 of 1

WebGL

Posted: Thu Apr 12, 2018 7:59 am
by elmstrom
Hello

Do i have to do something special to support WebGL, i have updatet to 3.0 and made a webGL build of a working game, but it cannot connect. I have tried runing it locally in Edge and on a web server then loaded in chrome.
Both with same result, no connection (the game loads fine and playes fine, but does not get data from easysave webserver).

Code: Select all

        cloud = new ES3Cloud("REMOVED", "REMOVED");
        yield return StartCoroutine(cloud.DownloadFile("bogListe.es3"));
        bogListe = ES3.Load("bogListe", "bogListe.es3", new Dictionary<string, BogClass>());

        if (cloud.isError)
        {
            isInternet = false;
            inetIcon.GetComponent<SpriteRenderer>().sprite = inetFalse;
        }

Cheers
Rune

Re: WebGL

Posted: Thu Apr 12, 2018 8:16 am
by Joel
Hi there,

Is your WebGL application on the same server as your app is installed in? If not, to communicate with external servers in WebGL, Unity requires that you set up CORS.

There's information on doing this in the Using the WWW or WebRequest classes in WebGL section of Unity's WebGL Networking docs, but you should just be able to contact your server to provider and ask them to enable CORS.

If that doesn't fix your error, please could you let me know what error is being thrown by the ES3Cloud object?

All the best,
Joel

Re: WebGL

Posted: Thu Apr 12, 2018 12:52 pm
by elmstrom
It is on the same server, the cloud.error is "Error: Unknown Error", so does not help alot.

Re: WebGL

Posted: Thu Apr 12, 2018 1:01 pm
by elmstrom
Now it works, removed "www" from the URL.

Re: WebGL

Posted: Thu Apr 12, 2018 1:59 pm
by elmstrom
New error: ES3.Save<Dictionary<string, BogClass>>("biblitek", bibliotek, "main.es3");

Triggers this in editor:

Code: Select all

FormatException: Expected ',' separating properties or '"' before property name, found 'REMOVED (CAUSE FORUM ERROR)'.
ES3Internal.ES3JSONReader.ReadPropertyName () (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3JSONReader.cs:62)
ES3Reader+ES3ReaderRawEnumerator+<GetEnumerator>c__Iterator0.MoveNext () (at Assets/Plugins/Easy Save 3/Scripts/Readers/ES3Reader.cs:416)
ES3Writer.Merge (.ES3Reader reader) (at Assets/Plugins/Easy Save 3/Scripts/Writers/ES3Writer.cs:351)
ES3Writer.Merge () (at Assets/Plugins/Easy Save 3/Scripts/Writers/ES3Writer.cs:341)
ES3Writer.Save () (at Assets/Plugins/Easy Save 3/Scripts/Writers/ES3Writer.cs:360)
ES3.Save[Dictionary`2] (System.String key, System.Object value, .ES3Settings settings) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:41)
ES3.Save[Dictionary`2] (System.String key, System.Object value, System.String filePath) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:51)
ES3script.LoadBogInfo (System.String tempKode) (at Assets/script/menu/ES3script.cs:283)
ES3script+<CheckKodeCR>c__Iterator2.MoveNext () (at Assets/script/menu/ES3script.cs:947)
UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17)
This is error from chrome:

Code: Select all

InvalidCastException: Unable to cast object of type 'Dictionary`2' to type 'IList'.

 
(Filename: currently not available on il2cpp Line: -1)

Re: WebGL

Posted: Fri Apr 13, 2018 9:11 am
by Joel
Hi there,

I don't appear to be getting this issue at my end.

First, please try deleting your save data incase there's corrupt data from a previous error. If this does not fix your problem, please could you PM me a basic project and instructions to replicate this?

All the best,
Joel