game: adding signin to supabase
This commit is contained in:
parent
774ec4831b
commit
d69056c9c1
5 changed files with 117 additions and 32 deletions
|
@ -195,8 +195,8 @@ Light:
|
||||||
m_LightShadowCasterMode: 0
|
m_LightShadowCasterMode: 0
|
||||||
m_AreaSize: {x: 1, y: 1}
|
m_AreaSize: {x: 1, y: 1}
|
||||||
m_BounceIntensity: 1
|
m_BounceIntensity: 1
|
||||||
m_ColorTemperature: 6570
|
m_ColorTemperature: 5512
|
||||||
m_UseColorTemperature: 0
|
m_UseColorTemperature: 1
|
||||||
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
|
m_BoundingSphereOverride: {x: 0, y: 0, z: 0, w: 0}
|
||||||
m_UseBoundingSphereOverride: 0
|
m_UseBoundingSphereOverride: 0
|
||||||
m_UseViewFrustumForShadowCasterCull: 1
|
m_UseViewFrustumForShadowCasterCull: 1
|
||||||
|
@ -248,6 +248,22 @@ PrefabInstance:
|
||||||
serializedVersion: 3
|
serializedVersion: 3
|
||||||
m_TransformParent: {fileID: 0}
|
m_TransformParent: {fileID: 0}
|
||||||
m_Modifications:
|
m_Modifications:
|
||||||
|
- target: {fileID: 1767192439, guid: f6336ac4ac8b4d34bc5072418cdc62a0, type: 3}
|
||||||
|
propertyPath: m_BackGroundColor.a
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1767192439, guid: f6336ac4ac8b4d34bc5072418cdc62a0, type: 3}
|
||||||
|
propertyPath: m_BackGroundColor.b
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1767192439, guid: f6336ac4ac8b4d34bc5072418cdc62a0, type: 3}
|
||||||
|
propertyPath: m_BackGroundColor.g
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 1767192439, guid: f6336ac4ac8b4d34bc5072418cdc62a0, type: 3}
|
||||||
|
propertyPath: m_BackGroundColor.r
|
||||||
|
value: 0
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 1717954561962503725, guid: f6336ac4ac8b4d34bc5072418cdc62a0, type: 3}
|
- target: {fileID: 1717954561962503725, guid: f6336ac4ac8b4d34bc5072418cdc62a0, type: 3}
|
||||||
propertyPath: m_Name
|
propertyPath: m_Name
|
||||||
value: XR Origin (XR Rig)
|
value: XR Origin (XR Rig)
|
||||||
|
@ -332,6 +348,8 @@ MonoBehaviour:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
url: https://fchobpauqasfebohuuam.supabase.co
|
url: https://fchobpauqasfebohuuam.supabase.co
|
||||||
anonKey: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZjaG9icGF1cWFzZmVib2h1dWFtIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MzczNTYyNTUsImV4cCI6MjA1MjkzMjI1NX0.LkwCnzjtf8CPLrm6OONkjyjxZW8jE05V_spbOEeAXEM
|
anonKey: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZjaG9icGF1cWFzZmVib2h1dWFtIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MzczNTYyNTUsImV4cCI6MjA1MjkzMjI1NX0.LkwCnzjtf8CPLrm6OONkjyjxZW8jE05V_spbOEeAXEM
|
||||||
|
email: Ryanlin.hr@gmail.com
|
||||||
|
password: 1234567890
|
||||||
--- !u!4 &545637505
|
--- !u!4 &545637505
|
||||||
Transform:
|
Transform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|
|
@ -1,13 +1,18 @@
|
||||||
using Postgrest;
|
|
||||||
using Postgrest.Attributes;
|
|
||||||
using Postgrest.Models;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Supabase;
|
using Supabase;
|
||||||
|
using Supabase.Gotrue;
|
||||||
|
using Client = Supabase.Client;
|
||||||
|
|
||||||
public class Backend : MonoBehaviour
|
public class Backend : MonoBehaviour
|
||||||
{
|
{
|
||||||
[SerializeField] private string url;
|
[SerializeField] private string url;
|
||||||
[SerializeField] private string anonKey;
|
[SerializeField] private string anonKey;
|
||||||
|
public Client Client;
|
||||||
|
public string email;
|
||||||
|
public string password;
|
||||||
|
public Session Session;
|
||||||
|
|
||||||
|
|
||||||
private async void Start()
|
private async void Start()
|
||||||
{
|
{
|
||||||
|
@ -16,34 +21,63 @@ public class Backend : MonoBehaviour
|
||||||
AutoConnectRealtime = true
|
AutoConnectRealtime = true
|
||||||
};
|
};
|
||||||
|
|
||||||
var client = new Supabase.Client(url, anonKey, options);
|
Client = new Supabase.Client(url, anonKey, options);
|
||||||
await client.InitializeAsync();
|
await Client.InitializeAsync().ContinueWith(task =>
|
||||||
var test = new Test
|
|
||||||
{
|
{
|
||||||
Name = "John",
|
if (!task.IsCompletedSuccessfully)
|
||||||
Score = 100
|
|
||||||
};
|
|
||||||
await client.From<Test>().Insert(test, new QueryOptions { Returning = QueryOptions.ReturnType.Representation })
|
|
||||||
.ContinueWith(task =>
|
|
||||||
{
|
|
||||||
if (task.IsCompletedSuccessfully)
|
|
||||||
{
|
|
||||||
var result = task.Result;
|
|
||||||
Debug.Log(result.Models[0].Name);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
Debug.LogError(task.Exception);
|
Debug.LogError(task.Exception);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Log("Supabase Initialized");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
SignUp(email, password, "Test");
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void SendData(string uid, int score, string displayName, int daysPlayed, int customersHelped, int customersHelpedWrongly)
|
||||||
|
{
|
||||||
|
var user= new Users
|
||||||
|
{
|
||||||
|
uid = uid,
|
||||||
|
score = score,
|
||||||
|
displayName = displayName,
|
||||||
|
daysPlayed = daysPlayed,
|
||||||
|
customersHelped = customersHelped,
|
||||||
|
customersHelpedWrongly = customersHelpedWrongly,
|
||||||
|
};
|
||||||
|
await Client.From<Users>().Insert(user).ContinueWith(SendTask =>
|
||||||
|
{
|
||||||
|
if (!SendTask.IsCompletedSuccessfully)
|
||||||
|
{
|
||||||
|
Debug.LogError(SendTask.Exception);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
Debug.Log("Data Sent Sucessfully");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[Table("test")]
|
public async void SignUp(string email, string password, string displayName)
|
||||||
public class Test : BaseModel
|
|
||||||
{
|
{
|
||||||
[Column("name")] public string Name { get; set; }
|
Session = await Client.Auth.SignUp(email, password);
|
||||||
|
Debug.Log(Session.User.Id);
|
||||||
[Column("score")] public int Score { get; set; }
|
SendData(Session.User.Id, 0, displayName, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void SignIn(string email, string password)
|
||||||
|
{
|
||||||
|
Session = await Client.Auth.SignIn(email, password);
|
||||||
|
Debug.Log(Session.User.Id);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void GetData()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
22
SSLR/Assets/Scripts/supabaseClasses.cs
Normal file
22
SSLR/Assets/Scripts/supabaseClasses.cs
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
using Postgrest.Attributes;
|
||||||
|
using Postgrest.Models;
|
||||||
|
|
||||||
|
[Table("test")]
|
||||||
|
public class Test : BaseModel
|
||||||
|
{
|
||||||
|
[Column()] public string name { get; set; }
|
||||||
|
[Column()] public int score { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
[Table("users")]
|
||||||
|
public class Users : BaseModel
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
[Column()] public string uid { get; set; }
|
||||||
|
[Column()] public int score { get; set; }
|
||||||
|
[Column()] public string displayName { get; set; }
|
||||||
|
[Column()] public int daysPlayed { get; set; }
|
||||||
|
[Column()] public int customersHelped { get; set; }
|
||||||
|
[Column()] public int customersHelpedWrongly { get; set; }
|
||||||
|
}
|
11
SSLR/Assets/Scripts/supabaseClasses.cs.meta
Normal file
11
SSLR/Assets/Scripts/supabaseClasses.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b645c5873f8e2e749b06822b7f32e31f
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -12,8 +12,8 @@ PlayerSettings:
|
||||||
targetDevice: 2
|
targetDevice: 2
|
||||||
useOnDemandResources: 0
|
useOnDemandResources: 0
|
||||||
accelerometerFrequency: 60
|
accelerometerFrequency: 60
|
||||||
companyName: DefaultCompany
|
companyName: SweetStarryLilRabbits
|
||||||
productName: SSLR
|
productName: SolaceOfService
|
||||||
defaultCursor: {fileID: 0}
|
defaultCursor: {fileID: 0}
|
||||||
cursorHotspot: {x: 0, y: 0}
|
cursorHotspot: {x: 0, y: 0}
|
||||||
m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1}
|
m_SplashScreenBackgroundColor: {r: 0.13725491, g: 0.12156863, b: 0.1254902, a: 1}
|
||||||
|
|
Loading…
Add table
Reference in a new issue