|
4 | 4 | using SimpleJSON; |
5 | 5 | using System; |
6 | 6 | using System.Collections.Generic; |
| 7 | +using Discord; |
7 | 8 |
|
8 | 9 | namespace Playroom |
9 | 10 | { |
@@ -451,6 +452,63 @@ public void StartDiscordPurchase(string skuId, Action<string> callback = null) |
451 | 452 | CallbackManager.RegisterCallback(callback, skuId); |
452 | 453 | StartDiscordPurchaseInternal(skuId, DiscordPurchaseCallback); |
453 | 454 | } |
| 455 | + |
| 456 | + public void GetDiscordSkus(Action<List<DiscordSku>> callback) |
| 457 | + { |
| 458 | + CheckPlayRoomInitialized(); |
| 459 | + CallbackManager.RegisterCallback(callback, "discordSkus"); |
| 460 | + GetDiscordSkusInternal(DiscordSkusCallback); |
| 461 | + } |
| 462 | + |
| 463 | + [MonoPInvokeCallback(typeof(Action<string>))] |
| 464 | + private static void DiscordSkusCallback(string data) |
| 465 | + { |
| 466 | + try |
| 467 | + { |
| 468 | + List<DiscordSku> list = DiscordSku.FromJSON(data); |
| 469 | + CallbackManager.InvokeCallback("discordSkus", list); |
| 470 | + } |
| 471 | + catch (Exception e) |
| 472 | + { |
| 473 | + Debug.LogError($"[Unity]: Error in Discord SKU: {e}"); |
| 474 | + throw; |
| 475 | + } |
| 476 | + } |
| 477 | + |
| 478 | + public void GetDiscordEntitlements(Action<List<DiscordEntitlement>> callback) |
| 479 | + { |
| 480 | + CheckPlayRoomInitialized(); |
| 481 | + CallbackManager.RegisterCallback(callback, "discordEntitlements"); |
| 482 | + GetDiscordEntitlementsInternal(DiscordEntitlementsCallback); |
| 483 | + } |
| 484 | + |
| 485 | + [MonoPInvokeCallback(typeof(Action<string>))] |
| 486 | + private static void DiscordEntitlementsCallback(string data) |
| 487 | + { |
| 488 | + try |
| 489 | + { |
| 490 | + List<DiscordEntitlement> list = DiscordEntitlement.FromJSON(data); |
| 491 | + CallbackManager.InvokeCallback("discordEntitlements", list); |
| 492 | + } |
| 493 | + catch (Exception e) |
| 494 | + { |
| 495 | + Debug.LogError($"[Unity]: Error in discord Entitlements: {e}"); |
| 496 | + throw; |
| 497 | + } |
| 498 | + } |
| 499 | + |
| 500 | + public void DiscordPriceFormat(float price, string currency, string locale, Action<string> callback) |
| 501 | + { |
| 502 | + CheckPlayRoomInitialized(); |
| 503 | + CallbackManager.RegisterCallback(callback, "formattedPrice"); |
| 504 | + DiscordPriceFormatInternal(price, currency, locale, DiscordPriceFormatCallbackInvoker); |
| 505 | + } |
| 506 | + |
| 507 | + [MonoPInvokeCallback(typeof(Action<string>))] |
| 508 | + private static void DiscordPriceFormatCallbackInvoker(string formattedPrice) |
| 509 | + { |
| 510 | + CallbackManager.InvokeCallback("formattedPrice", formattedPrice); |
| 511 | + } |
454 | 512 | #endregion |
455 | 513 |
|
456 | 514 | #region Callbacks |
|
0 commit comments