@@ -12,7 +12,7 @@ namespace VirtueSky.Iap
12
12
public class IapManager : MonoBehaviour , IDetailedStoreListener
13
13
{
14
14
public bool dontDestroyOnLoad = true ;
15
- public static IapManager Instance ;
15
+ private static IapManager _instance ;
16
16
public static event Action < string > OnPurchaseSucceedEvent ;
17
17
public static event Action < string > OnPurchaseFailedEvent ;
18
18
public static event Action < Product > OnIapTrackingRevenueEvent ;
@@ -30,9 +30,9 @@ private void Awake()
30
30
DontDestroyOnLoad ( this . gameObject ) ;
31
31
}
32
32
33
- if ( Instance == null )
33
+ if ( _instance == null )
34
34
{
35
- Instance = this ;
35
+ _instance = this ;
36
36
}
37
37
else
38
38
{
@@ -42,7 +42,7 @@ private void Awake()
42
42
43
43
private void OnDestroy ( )
44
44
{
45
- if ( Instance == this ) Instance = null ;
45
+ if ( _instance == this ) _instance = null ;
46
46
}
47
47
48
48
private void Start ( )
@@ -249,50 +249,67 @@ private static void AutoInitialize()
249
249
}
250
250
}
251
251
252
- #region API
252
+ #region Internal API
253
253
254
- public IapDataProduct PurchaseProduct ( string id )
254
+ private IapDataProduct InternalPurchaseProduct ( string id )
255
255
{
256
256
OnShowIapNativePopupEvent ? . Invoke ( true ) ;
257
257
var product = iapSettings . GetIapProduct ( id ) ;
258
258
PurchaseProductInternal ( product ) ;
259
259
return product ;
260
260
}
261
261
262
- public IapDataProduct PurchaseProduct ( IapDataProduct product )
262
+ private IapDataProduct InternalPurchaseProduct ( IapDataProduct product )
263
263
{
264
264
OnShowIapNativePopupEvent ? . Invoke ( true ) ;
265
265
PurchaseProductInternal ( product ) ;
266
266
return product ;
267
267
}
268
268
269
- public bool IsPurchasedProduct ( IapDataProduct product )
269
+ private bool InternalIsPurchasedProduct ( IapDataProduct product )
270
270
{
271
271
if ( _controller == null ) return false ;
272
272
return ConvertProductType ( product . iapProductType ) == ProductType . NonConsumable &&
273
273
_controller . products . WithID ( product . Id ) . hasReceipt ;
274
274
}
275
275
276
- public bool IsPurchasedProduct ( string id )
276
+ private bool InternalIsPurchasedProduct ( string id )
277
277
{
278
278
if ( _controller == null ) return false ;
279
279
return ConvertProductType ( iapSettings . GetIapProduct ( id ) . iapProductType ) == ProductType . NonConsumable &&
280
280
_controller . products . WithID ( id ) . hasReceipt ;
281
281
}
282
282
283
- public string LocalizedPriceProduct ( IapDataProduct product )
283
+ private string InternalLocalizedPriceProduct ( IapDataProduct product )
284
284
{
285
285
if ( _controller == null ) return "" ;
286
286
return _controller . products . WithID ( product . Id ) . metadata . localizedPriceString ;
287
287
}
288
288
289
- public string LocalizedPriceProduct ( string id )
289
+ private string InternalLocalizedPriceProduct ( string id )
290
290
{
291
291
if ( _controller == null ) return "" ;
292
292
return _controller . products . WithID ( id ) . metadata . localizedPriceString ;
293
293
}
294
294
295
295
#endregion
296
+
297
+ #region Public API
298
+
299
+ public static IapDataProduct PurchaseProduct ( string id ) => _instance . InternalPurchaseProduct ( id ) ;
300
+
301
+ public static IapDataProduct PurchaseProduct ( IapDataProduct product ) =>
302
+ _instance . InternalPurchaseProduct ( product ) ;
303
+
304
+ public static bool IsPurchasedProduct ( IapDataProduct product ) => _instance . InternalIsPurchasedProduct ( product ) ;
305
+ public static bool IsPurchasedProduct ( string id ) => _instance . InternalIsPurchasedProduct ( id ) ;
306
+
307
+ public static string LocalizedPriceProduct ( IapDataProduct product ) =>
308
+ _instance . InternalLocalizedPriceProduct ( product ) ;
309
+
310
+ public static string LocalizedPriceProduct ( string id ) => _instance . InternalLocalizedPriceProduct ( id ) ;
311
+
312
+ #endregion
296
313
}
297
314
}
298
315
0 commit comments