You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

75 lines
2.2 KiB

  1. // Copyright (C) 2015 Google, Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. using System;
  15. using System.Collections.Generic;
  16. using GoogleMobileAds.Common;
  17. using UnityEngine;
  18. namespace GoogleMobileAds.Api
  19. {
  20. public class CustomNativeTemplateAd
  21. {
  22. private ICustomNativeTemplateClient client;
  23. internal CustomNativeTemplateAd(ICustomNativeTemplateClient client)
  24. {
  25. this.client = client;
  26. }
  27. public List<string> GetAvailableAssetNames()
  28. {
  29. return this.client.GetAvailableAssetNames();
  30. }
  31. public string GetCustomTemplateId()
  32. {
  33. return this.client.GetTemplateId();
  34. }
  35. // Get image asset corresponding to the key parameter of custom native template ad as a
  36. // Texture2D. If the asset key does not map to an existing asset, a null object will be
  37. // returned.
  38. public Texture2D GetTexture2D(string key)
  39. {
  40. byte[] imageAssetAsByteArray = this.client.GetImageByteArray(key);
  41. if (imageAssetAsByteArray == null)
  42. {
  43. return null;
  44. }
  45. return Utils.GetTexture2DFromByteArray(imageAssetAsByteArray);
  46. }
  47. // Get text asset corresponding to the key parameter of custom native template ad as a
  48. // string. If the asset key does not map to an existing asset, a null object will be
  49. // returned.
  50. public string GetText(string key)
  51. {
  52. return this.client.GetText(key);
  53. }
  54. public void PerformClick(string assetName)
  55. {
  56. this.client.PerformClick(assetName);
  57. }
  58. public void RecordImpression()
  59. {
  60. this.client.RecordImpression();
  61. }
  62. }
  63. }