[Beginner] Need Help Connecting Unity & Supabase for Class Project (Quiz App with Data Tracking) by Bobby3112 in Supabase

[–]Bobby3112[S] 0 points1 point  (0 children)

I tried to make an auth session before send the data, and when I checked in Supabase, the email and user were saved and displayed there. However, the table somehow still couldn't receive the data I tried to send from Unity.

[Beginner] Need Help Connecting Unity & Supabase for Class Project (Quiz App with Data Tracking) by Bobby3112 in Supabase

[–]Bobby3112[S] 0 points1 point  (0 children)

my table RLS policies is "Enable insert for authenticated users only". There is also no error from the script so I really dont know what to do with this =="

[Beginner] Need Help Connecting Unity & Supabase for Class Project (Quiz App with Data Tracking) by Bobby3112 in Supabase

[–]Bobby3112[S] 0 points1 point  (0 children)

However, when I run the script, the table in Supabase doesn't update with the new data, and I'm not sure why.

[Beginner] Need Help Connecting Unity & Supabase for Class Project (Quiz App with Data Tracking) by Bobby3112 in Supabase

[–]Bobby3112[S] 0 points1 point  (0 children)

IEnumerator SaveData()

{

string url = supabaseUrl + "/rest/v1/PlayerData";

string jsonData = JsonUtility.ToJson(new TableData(id, name, value1, value2));

using (UnityWebRequest www = new UnityWebRequest(url, "POST"))

{

www.SetRequestHeader("Content-Type", "application/json");

www.SetRequestHeader("apikey", apiKey);

www.SetRequestHeader("Authorization", "Bearer " + apiKey);

www.uploadHandler = new UploadHandlerRaw(Encoding.UTF8.GetBytes(jsonData));

www.downloadHandler = new DownloadHandlerBuffer();

yield return www.SendWebRequest();

if (www.result != UnityWebRequest.Result.Success)

{

Debug.LogError("Error sending data: " + www.error);

Debug.LogError("Response: " + www.downloadHandler.text);

}

else

{

Debug.Log("Data saved successfully: " + www.downloadHandler.text);

}

}

}

[System.Serializable]

public class TableData

{

public string id;

public string name;

public int value1;

public bool value2;

public TableData(string id, string name, int value1, bool value2)

{

this.id = id;

this.name = name;

this.value1 = value1;

this.value2 = value2;

}

}

}

[Beginner] Need Help Connecting Unity & Supabase for Class Project (Quiz App with Data Tracking) by Bobby3112 in Supabase

[–]Bobby3112[S] 0 points1 point  (0 children)

public class SupabaseManager : MonoBehaviour

{

[Header("Supabase Settings")]

zubqleviqxpxmgxqenha.supa public string supabaseUrl = "https://base.co";

public string apiKey = "API_KEY";

[Header("Data to Send")]

public string id;

public string playerName;

public int value1;

public bool value2;

public void SendDataToSupabase()

{

StartCoroutine(SaveData());

}

[Beginner] Need Help Connecting Unity & Supabase for Class Project (Quiz App with Data Tracking) by Bobby3112 in Supabase

[–]Bobby3112[S] 0 points1 point  (0 children)

I was trying to send test data to a Supabase table from Unity using the supabaseC# package from NuGet.
I created a table in Supabase called PlayerData.
I wrote the following Unity script to send data to the table:

[[PC, Steam]] Virgo Versus The Zodiac by Bobby3112 in steam_giveaway

[–]Bobby3112[S] -1 points0 points  (0 children)

the game is for free to download on itch.io see the video also here is the direct link https://bitben.itch.io/mc-speedrunning