Question by
FunkyShammy · Jul 26, 2018 at 01:45 AM ·
unity 2dscorejsonposthttpwebrequest
POST JSON method does not work when project has been exported to WEBGL and upload to firebase,help please?
I have a database set up on firebase and when i run my game in the unity edtitor and as a standalone exported Windows .exe file, the call gets made correctly to the database and JSON data gets posted correctly. However when I export the exact same project to WEBGL and upload it to my firebase hosting server, the JSON call does not work. Here is my code, could someone please help?
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class GameOverMenu : MonoBehaviour
{
public InputField nameInputField;
public void MainMenu()
{
SceneManager.LoadScene("Menu");
}
public void SubmitScore()
{
StartCoroutine(SendScore());
SceneManager.LoadScene("Menu");
}
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public IEnumerator SendScore()
{
Scoreboard s = new Scoreboard(nameInputField.text, PlayerPrefs.GetInt("Score"), PlayerPrefs.GetInt("Seed"));
Dictionary<string, string> headers = new Dictionary<string, string>();
headers.Add("Content-Type", "application/json");
Hashtable data = new Hashtable();
data.Add("name", s.Name);
data.Add("score", s.Score);
data.Add("seed", s.Seed);
UnityHTTP.Request postRequest = new UnityHTTP.Request("post", "https://alexclearythesisgame.firebaseio.com/Scoreboard.json", data);
postRequest.Send();
yield return postRequest.isDone;
}
}
Comment
Your answer
Follow this Question
Related Questions
How to stay connected on a website to send WWWForm? 1 Answer
HTTP to WWW Help --Small Sample Code Conversion 0 Answers
How do delete the lowest value on my list? 0 Answers
[WEBGL] Post json - complicated structure 0 Answers
loading prefab from path 2 Answers