Configuration.cs 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #if UNITY_EDITOR
  2. using System.Collections.Generic;
  3. namespace UnityEngine.Monetization
  4. {
  5. sealed class Configuration
  6. {
  7. public bool enabled { get; private set; }
  8. public string defaultPlacement { get; private set; }
  9. public Dictionary<string, PlacementContent> placementContents { get; private set; }
  10. public Configuration(string configurationResponse)
  11. {
  12. var configurationJson = (Dictionary<string, object>)MiniJSON.Json.Deserialize(configurationResponse);
  13. enabled = (bool)configurationJson["enabled"];
  14. placementContents = new Dictionary<string, PlacementContent>();
  15. foreach (Dictionary<string, object> placement in (List<object>)configurationJson["placements"])
  16. {
  17. var id = (string)placement["id"];
  18. var allowSkip = (bool)placement["allowSkip"];
  19. if ((bool)placement["default"])
  20. {
  21. defaultPlacement = id;
  22. }
  23. foreach (object type in (List<object>)placement["adTypes"])
  24. {
  25. if ((string)type == "IAP")
  26. {
  27. EditorPromoAdOperations operations = new EditorPromoAdOperations();
  28. operations.allowSkip = allowSkip;
  29. operations.placementId = id;
  30. PromoAdPlacementContent placementContent = new PromoAdPlacementContent(id, operations);
  31. placementContents.Add(id, placementContent);
  32. placementContent.extras = new Dictionary<string, object> {};
  33. break;
  34. }
  35. if ((string)type == "VIDEO")
  36. {
  37. EditorShowAdOperations operations = new EditorShowAdOperations();
  38. operations.allowSkip = allowSkip;
  39. operations.placementId = id;
  40. ShowAdPlacementContent placementContent = new ShowAdPlacementContent(id, operations);
  41. placementContents.Add(id, placementContent);
  42. placementContent.extras = new Dictionary<string, object> {};
  43. break;
  44. }
  45. }
  46. }
  47. }
  48. }
  49. }
  50. #endif