File tree Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Expand file tree Collapse file tree 2 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ public class LootLockerServerApi : MonoBehaviour
21
21
private const int MaxRetries = 3 ;
22
22
private int _tries ;
23
23
24
- public static LootLockerServerApi GetInstance ( )
24
+ public static void Instantiate ( )
25
25
{
26
26
if ( _instance == null )
27
27
{
@@ -30,10 +30,9 @@ public static LootLockerServerApi GetInstance()
30
30
if ( Application . isPlaying )
31
31
DontDestroyOnLoad ( _instance . gameObject ) ;
32
32
}
33
- return _instance ;
34
33
}
35
34
36
- private static void DestroyInstance ( )
35
+ public static void Reset ( )
37
36
{
38
37
if ( _instance == null ) return ;
39
38
Destroy ( _instance . gameObject ) ;
@@ -44,13 +43,18 @@ private static void DestroyInstance()
44
43
[ InitializeOnEnterPlayMode ]
45
44
static void OnEnterPlaymodeInEditor ( EnterPlayModeOptions options )
46
45
{
47
- DestroyInstance ( ) ;
46
+ Reset ( ) ;
48
47
}
49
48
#endif
50
49
51
50
public static void SendRequest ( LootLockerServerRequest request , Action < LootLockerResponse > OnServerResponse = null )
52
51
{
53
- GetInstance ( ) . _SendRequest ( request , OnServerResponse ) ;
52
+ if ( _instance == null )
53
+ {
54
+ Instantiate ( ) ;
55
+ }
56
+
57
+ _instance . _SendRequest ( request , OnServerResponse ) ;
54
58
}
55
59
56
60
private void _SendRequest ( LootLockerServerRequest request , Action < LootLockerResponse > OnServerResponse = null )
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ public static string GetCurrentPlatform()
35
35
static bool initialized ;
36
36
static bool Init ( )
37
37
{
38
- LootLockerServerApi . GetInstance ( ) ;
38
+ LootLockerServerApi . Instantiate ( ) ;
39
39
return LoadConfig ( ) ;
40
40
}
41
41
@@ -48,7 +48,7 @@ static bool Init()
48
48
/// <returns>True if initialized successfully, false otherwise</returns>
49
49
public static bool Init ( string apiKey , string gameVersion , string domainKey )
50
50
{
51
- LootLockerServerApi . GetInstance ( ) ;
51
+ LootLockerServerApi . Instantiate ( ) ;
52
52
return LootLockerConfig . CreateNewSettings ( apiKey , gameVersion , domainKey ) ;
53
53
}
54
54
You can’t perform that action at this time.
0 commit comments