Quantcast
Channel: Questions in topic: "webgl"
Viewing all articles
Browse latest Browse all 2390

UnityWebRequest not working in WebGL build

$
0
0
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()); }

Viewing all articles
Browse latest Browse all 2390

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>