25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

40 satır
1.3 KiB

  1. // Copyright (C) 2017 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 UnityEngine;
  17. namespace GoogleMobileAds.Common
  18. {
  19. internal class Utils
  20. {
  21. public static Texture2D GetTexture2DFromByteArray(byte[] img)
  22. {
  23. // Create a texture. Texture size does not matter, since
  24. // LoadImage will replace with with incoming image size.
  25. Texture2D nativeAdTexture = new Texture2D(1, 1);
  26. if (!nativeAdTexture.LoadImage(img))
  27. {
  28. throw new InvalidOperationException(@"Could not load custom native template
  29. image asset as texture");
  30. }
  31. return nativeAdTexture;
  32. }
  33. }
  34. }