From 53d5611c5c8631f5ffefe560da5dc0bc07948d38 Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 21 Jan 2025 17:37:40 +0800 Subject: [PATCH] game: testing backend --- SSLR/Assets/Scenes/RyanPlayground.unity | 65 +++++++++++++++++-- SSLR/Assets/Scripts/Backend.cs | 48 +++++++++++++- .../com.unity.services.core/Settings.json | 0 3 files changed, 107 insertions(+), 6 deletions(-) create mode 100644 SSLR/ProjectSettings/Packages/com.unity.services.core/Settings.json diff --git a/SSLR/Assets/Scenes/RyanPlayground.unity b/SSLR/Assets/Scenes/RyanPlayground.unity index 409b6a6..b00a8c2 100644 --- a/SSLR/Assets/Scenes/RyanPlayground.unity +++ b/SSLR/Assets/Scenes/RyanPlayground.unity @@ -38,7 +38,6 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0.18306622, g: 0.2287434, b: 0.30669293, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -210,13 +209,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 299639867} + serializedVersion: 2 m_LocalRotation: {x: 0.33079913, y: -0.0329763, z: 0.3034621, w: 0.8929699} m_LocalPosition: {x: 0, y: 3, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 37.647, y: 10.322, z: 41.066} --- !u!114 &299639870 MonoBehaviour: @@ -302,6 +301,52 @@ PrefabInstance: m_AddedGameObjects: [] m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: f6336ac4ac8b4d34bc5072418cdc62a0, type: 3} +--- !u!1 &545637503 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 545637505} + - component: {fileID: 545637504} + m_Layer: 0 + m_Name: test backend + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &545637504 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 545637503} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e8dc8c9a0f5dd0243895dc3a63323b85, type: 3} + m_Name: + m_EditorClassIdentifier: + url: https://fchobpauqasfebohuuam.supabase.co + anonKey: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZjaG9icGF1cWFzZmVib2h1dWFtIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MzczNTYyNTUsImV4cCI6MjA1MjkzMjI1NX0.LkwCnzjtf8CPLrm6OONkjyjxZW8jE05V_spbOEeAXEM +--- !u!4 &545637505 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 545637503} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 2.53231, y: -0.36813438, z: -1.4535393} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &756192406 GameObject: m_ObjectHideFlags: 0 @@ -340,13 +385,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 756192406} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: -1.6751227, y: -2.2229433, z: -23.114769} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1249617917 GameObject: @@ -447,13 +492,13 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1249617917} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 10, y: 10, z: 10} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!114 &1249617922 MonoBehaviour: @@ -614,11 +659,21 @@ Transform: m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 2092139007} + serializedVersion: 2 m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalPosition: {x: -1.6751227, y: -2.2229433, z: -23.114769} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1660057539 &9223372036854775807 +SceneRoots: + m_ObjectHideFlags: 0 + m_Roots: + - {fileID: 299639869} + - {fileID: 441087506} + - {fileID: 756192408} + - {fileID: 2092139010} + - {fileID: 1249617921} + - {fileID: 545637505} diff --git a/SSLR/Assets/Scripts/Backend.cs b/SSLR/Assets/Scripts/Backend.cs index 6efb94c..b55fb71 100644 --- a/SSLR/Assets/Scripts/Backend.cs +++ b/SSLR/Assets/Scripts/Backend.cs @@ -1,5 +1,51 @@ +using System; +using System.Threading.Tasks; using UnityEngine; +using Supabase; +using Supabase.Postgrest; +using Supabase.Postgrest.Attributes; +using Supabase.Postgrest.Models; + public class Backend : MonoBehaviour { - + [SerializeField] private string url; + [SerializeField] private string anonKey; + + private async void Start() + { + var options = new SupabaseOptions + { + AutoConnectRealtime = true + }; + + var client = new Supabase.Client(url, anonKey, options); + await client.InitializeAsync(); + var test = new Test + { + Name = "John", + Score = 100 + }; + await client.From().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); + } + + }); + } } + +[Table("test")] +public class Test : BaseModel +{ + [Column("name")] public string Name { get; set; } + + [Column("score")] public int Score { get; set; } +} \ No newline at end of file diff --git a/SSLR/ProjectSettings/Packages/com.unity.services.core/Settings.json b/SSLR/ProjectSettings/Packages/com.unity.services.core/Settings.json new file mode 100644 index 0000000..e69de29