Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by josh_schulz · Feb 05, 2019 at 02:40 AM · webglnot workingwwwform

UnityWebRequest not working in WebGL build

My game works perfectly fine from within the Unity editor, but as soon as I upload the WebGL build to my website, everything works until I click the leaderboard button which contains the Unitywebrequest. I have been working on this for awhile, trying to understand. Thank you in advance.

Here's the script:

 IEnumerator GetScores()
 {
     using (UnityWebRequest www = UnityWebRequest.Get(webURL + publicCode + "/quote"))
     {
         yield return www.SendWebRequest();

         if (www.isNetworkError || www.isHttpError)
         {
             Debug.Log(www.error);
         }
         else
         {
             string results = www.downloadHandler.text;
             string[] splitResults = results.Split(new char[] { ',', '\n' }); //Contains lots of "Joshua16"  "16"  "0"  ""  "1/24/2019 10:26:08 PM"

             string[] TenNames = new string[10];
             string[] TenScores = new string[10];
             for (int j = 0; j < 50; j++)
             {
                 if (j == 0 || j == 5 || j == 10 || j == 15 || j == 20 || j == 25 || j == 30 || j == 35 || j == 40 || j == 45)
                 {
                     splitResults[j] = splitResults[j].Trim('\"');
                     TenNames[j / 5] = splitResults[j];
                 }
                 if ((j == 1 || j == 6 || j == 11 || j == 16 || j == 21 || j == 26 || j == 31 || j == 36 || j == 41 || j == 46))
                 {
                     splitResults[j] = splitResults[j].Trim('\"');
                     TenScores[j / 5] = splitResults[j];
                 }
             }

             OneName.text = TenNames[0];
             OneScore.text = TenScores[0];
             TwoName.text = TenNames[1];
             TwoScore.text = TenScores[1];
             ThreeName.text = TenNames[2];
             ThreeScore.text = TenScores[2];
             FourName.text = TenNames[3];
             FourScore.text = TenScores[3];
             FiveName.text = TenNames[4];
             FiveScore.text = TenScores[4];
             SixName.text = TenNames[5];
             SixScore.text = TenScores[5];
             SevenName.text = TenNames[6];
             SevenScore.text = TenScores[6];
             EightName.text = TenNames[7];
             EightScore.text = TenScores[7];
             NineName.text = TenNames[8];
             NineScore.text = TenScores[8];
             TenName.text = TenNames[9];
             TenScore.text = TenScores[9];

         }
     }
 }
 public void getScores()
 {
     StartCoroutine(GetScores());
 }

 IEnumerator PostScores()
 {
     using (UnityWebRequest www = UnityWebRequest.Get(webURL + privateCode + "/add/" + UnityWebRequest.EscapeURL(nameField.text) + "/" + PlayerPrefs.GetFloat("currentHighScore")))
     {
         yield return www.SendWebRequest();
         if (www.isNetworkError || www.isHttpError)
         {
             Debug.Log(www.error);
         }
         else
         {
             Debug.Log("Form Upload Complete!");
         }
     }
     getScores();
 }
 public void postScores()
 {
     StartCoroutine(PostScores());
 }
Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image josh_schulz · Feb 05, 2019 at 02:43 AM 0
Share

Here is the URL of the game with the broken leaderboard if it helps:

https://joshaschulz.wixsite.com/chaitanic/euler-climb

2 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Bunny83 · Feb 05, 2019 at 01:31 PM

My first guess also was that it may be a permission issue. However i had a look at the network analysis of my firefox and there was no attempt of the two get requests whatsoever. So i simply checked the browser console and i've immediately found the issue ^^.


The URL you're trying to access is an "http" address while your site is hosted on an https server. https and http can not be mixed. The browser itself will block any http request from inside a https site.

Your URL starts with http://dreamlo.com/...


If I allow / unblock mixed content in my Firefox for your website (see here if you use firefox), the requests go through and i see the leaderboard. However this is not an option. A secure website has to handle all requests over https. Though it looks like that "dreamlo" website doesn't support ssl and doesn't have a certificate as well. So i would strongly recommend to not using this site. On the wiki there's a simple example how to setup your own server side highscore if your webserver supports PHP and provides a mysql database. Of course you would use https URLs and not http :)


As final note: Everybody can see the "privateCode" in the request URL. So it's extremely easy to "cheat". Though this can't really be prevented

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image josh_schulz · Feb 05, 2019 at 08:06 PM 0
Share

Thank you! I will look into this

avatar image Rugbug_Redfern · Jan 19, 2021 at 08:15 PM 0
Share

By the way, anyone else looking to use dreamlo for leaderboards in WebGL, it does support SSL, but not in the free version. You have to donate $5 and email the developer so they can set up an SSL leaderboard for you.

avatar image
1

Answer by kaarloew · Feb 05, 2019 at 06:46 AM

Maybe a CORS issue? https://blog.kongregate.com/unity-html5-cors-and-you/

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

109 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Hlw guys can anybody help me with with error. this is after building with webgl and deployed it to the server. This error comes when it suppose to download a response from a different server where my database is located. 0 Answers

json webGL no work Unity 2018.3.3f1 0 Answers

Game Builds Standalone But Not WebGL anymore 1 Answer

Screenshot in WebGL 0 Answers

WWW class on WebGL: URL is wrong 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges