1- using System ;
2- using System . Threading . Tasks ;
31using Game . Players ;
4- using Unity . Services . Authentication ;
5- using Unity . Services . Core ;
62using Util ;
73
8- // using Services.Util;
9- // using Unity.Services.CloudCode;
10- // using Unity.Services.Core.Environments;
11- // using System.Collections.Generic;
12-
134namespace Services
145{
156 /**
@@ -21,92 +12,10 @@ namespace Services
2112 */
2213 public static class UnityAuth
2314 {
24- private static bool _authFailed ;
25- private static bool _retrying ;
26-
2715 public static void InitUnityServices ( )
2816 {
29- GameLog . Log ( "Connecting " ) ;
30-
31- if ( Settings . DisableNetwork )
32- {
33- PlayerData . InitUser ( ) ;
34- }
35-
36- // if (!Util.IsInternetReachable() || _retrying)
37- // {
38- // return;
39- // }
40- //
41- // try
42- // {
43- // _retrying = true;
44- // var options = new InitializationOptions();
45- // options.SetEnvironmentName(Settings.UnityServicesDev);
46- // await UnityServices.InitializeAsync(options);
47- // // InitAnalytics();
48- //
49- // if (!AuthenticationService.Instance.IsSignedIn)
50- // {
51- // await SignInAnonymouslyAsync();
52- // }
53- //
54- // // In case we could not connect or do auth
55- // if (!AuthenticationService.Instance.IsSignedIn || _authFailed)
56- // {
57- // return;
58- // }
59- //
60- // CloudCodeResult response =
61- // await CloudCodeService.Instance.CallEndpointAsync<CloudCodeResult>(
62- // CloudFunctions.CloudCodeGetPlayerData, null);
63- //
64- // Dictionary<string, object> parameters = new Dictionary<string, object>()
65- // {
66- // { AnalyticsEvents.CloudCodeGetPlayerDataResponse, (int)CloudCodeGetPlayerDataResponse.NewPlayerSaved }
67- // };
68- //
69- // //UnityAnalytics.PublishEvent(AnalyticsEvents.CloudCodeGetPlayerData, parameters);
70- //
71- // GameLog.Log("Auth user id: " + AuthenticationService.Instance.PlayerId);
72- // GameLog.Log("CloudCodeGetPlayerData: " + response.Key + " " + response.Value);
73- // PlayerData.InitUser();
74- //
75- // _authFailed = false;
76- // _retrying = false;
77- // }
78- // catch (Exception e)
79- // {
80- // GameLog.LogWarning(e.ToString());
81- // _authFailed = true;
82- // _retrying = false;
83- // }
84- }
85-
86- private static async Task SignInAnonymouslyAsync ( )
87- {
88- try
89- {
90- await AuthenticationService . Instance . SignInAnonymouslyAsync ( ) ;
91- }
92- catch ( Exception e )
93- {
94- // Compare error code to CommonErrorCodes
95- // Notify the player with the proper error message
96- GameLog . Log ( e . ToString ( ) ) ;
97- _authFailed = true ;
98- _retrying = false ;
99- }
100- }
101-
102- private static bool AreUnityServicesLoaded ( )
103- {
104- return Settings . DisableNetwork || (
105- //!Util.IsInternetReachable() &&
106- UnityServices . State == ServicesInitializationState . Initialized &&
107- AuthenticationService . Instance . IsSignedIn &&
108- ! _authFailed &&
109- ! _retrying ) ;
17+ GameLog . Log ( "UnityAuth: offline-only mode; initializing local player data." ) ;
18+ PlayerData . InitUser ( ) ;
11019 }
11120 }
11221}
0 commit comments