public void OnUpdateLandingPageButtonClicked() { var landingPageInfoFields = new PartyKit.LandingPageInfoField[] { new PartyKit.LandingPageInfoField() { ID = "text1", Label = "Label 1", Value = "test text1" }, new PartyKit.LandingPageInfoField() { ID = "text2", Label = "Label 2", Value = "test text2" }, new PartyKit.LandingPageInfoField() { ID = "partySize", Label = "", Value = "4" }, new PartyKit.LandingPageInfoField() { ID = "partyMaxSize", Label = "", Value = "6" } }; var r = PartyKit.UpdateInviteLandingPageInfo(landingPageInfoFields); if (r == Trail.Result.Ok) { Debug.Log("Update landing page info succeeded"); } else { Debug.LogWarningFormat("Update landing page info failed: {0}", r); } }
private void OnPartyDataUpdated() { Debug.Log("Party data updated"); var data = PartyKit.GetPartyData(); for (int i = 0; i < data.Count; i++) { var field = data[i]; Debug.Log(string.Format("Entry: {0} - Key: {1} - Value: {2}", i, field.Key, field.Value)); } }
public void OnFinalizeInviteLoadingFailureButtonClicked() { var r = PartyKit.FinalizeInviteLoading(false); if (r.IsError()) { Debug.LogWarningFormat("Finalize invite loading failed: {0}", r); } else { Debug.Log("Finalize invite loading succeeded"); } }
public void OnLeavePartyButtonClicked() { var r = PartyKit.LeaveParty(); if (r.IsError()) { Debug.LogWarningFormat("Leave party failed: {0}", r); } else { Debug.Log("Leave party succeeded"); } }
public void OnShowInviteLinkButtonClicked() { var r = PartyKit.ShowInviteLink(); if (r == Trail.Result.Ok) { Debug.Log("Show invite link succeeded"); } else { Debug.LogWarningFormat("Show invite link failed: {0}", r); } }
public void OnUpdateInviteLoadingMessageButtonClicked() { var r = PartyKit.UpdateInviteLoadingMessage( string.Format("loading message #{0}", new System.Random().Next(1, 10000))); if (r.IsError()) { Debug.LogWarningFormat("Update invite loading message failed: {0}", r); } else { Debug.Log("Update invite loading message succeeded"); } }
public void OnUpdatePartyDataButtonClicked() { var partyDataFields = new PartyKit.PartyDataField[] { new PartyKit.PartyDataField("serverId", "xyz123"), new PartyKit.PartyDataField("serverMotD", "Hello, World") }; var r = PartyKit.UpdatePartyData(partyDataFields); if (r == Trail.Result.Ok) { Debug.Log("Update party data succeeded"); } else { Debug.LogWarningFormat("Update party data failed: {0}", r); } }
public void OnIsInviteLoadingButtonClicked() { Debug.Log(string.Format("Is invite loading: {0}", PartyKit.IsInviteLoading())); }
void Start() { if (!TrailConfig.InitializeSDKAtStartup && alwaysInitializeSDKAtStartup) { Debug.LogWarning("[TrailSDK] - Automatic Initialization is <color=red>disabled</color>, will manually call SDK.Init();"); SDK.Init(); } SDK.OnInitialized += (Trail.Result result) => { if (result != Trail.Result.Ok) { Debug.LogErrorFormat("Trail SDK init failed: {0}", result.ToString()); return; } Debug.LogFormat("Trail SDK init succeeded"); if (!TrailConfig.InitializeSDKAtStartup) { var finishGameLoadTaskResult = SDK.FinishGameLoadTask(); if (finishGameLoadTaskResult != Trail.Result.Ok) { Debug.LogErrorFormat("Failed to finish game load task: {0}", finishGameLoadTaskResult); } } this.GameUserID.text = string.Format("Game user ID: {0}", AuthKit.GetGameUserID()); this.PlayToken.text = string.Format("Play token: {0}", AuthKit.GetPlayToken()); SDK.OnFocusChanged += (this.OnGameActiveStatusChanged); this.OnGameActiveStatusChanged(SDK.IsGameFocused); PerformanceKit.OnDisplayResolutionChanged += OnBrowserResolutionChanged; OnBrowserResolutionChanged(Trail.Resolution.Zero); Debug.Log(string.Format("Is loading invite: {0}", PartyKit.IsInviteLoading())); var partyData = PartyKit.GetPartyData(); for (int i = 0; i < partyData.Count; i++) { var field = partyData[i]; Debug.Log(string.Format("Party data: {0} - Key: {1} - Value: {2}", i, field.Key, field.Value)); } PartyKit.OnPartyDataUpdated += OnPartyDataUpdated; SDK.StartupArg[] args; SDK.GetStartupArgs(out args); for (int i = 0; i < args.Length; ++i) { var arg = args[i]; Debug.Log(string.Format("Startup Arg #{0}: Name: \"{1}\", Length {2}", i, arg.Name, arg.Value.Length)); } string cloudStoragePath; FileKit.GetCloudStoragePath(out cloudStoragePath); Debug.Log("Cloud storage path: " + cloudStoragePath); AuthKit.GetFingerprint((res, fingerprint) => { if (res.IsOk()) { Debug.Log("Fingerprint: " + fingerprint); } else { Debug.LogErrorFormat("Failed to get fingerprint: {0}", res.ToString()); } }); #if !UNITY_EDITOR && UNITY_WEBGL var path = FileKit.GetCloudStoragePathFormatted("example.txt"); if (System.IO.File.Exists(path)) { inputField.text = System.IO.File.ReadAllText(path); } #endif }; UnityEngine.Object.DontDestroyOnLoad(this.gameObject); }