Giter Site home page Giter Site logo

googleads-mobile-unity-example's Introduction

** This project is currently on hold and I hope to have more time to update this project :( **

Google Mobile Ads Example for Unity

Features

  • Easy to use
  • Operation interface
  • Ad formats support:
    • Banner
    • Interstitial
    • Rewarded
    • Rewarded interstitial
    • (Optional) Native Ads Advanced (Unified)

Environment

  • Unity 2020.3.11f1
  • External Dependency Manager for Unity v1.2.165
  • Google Mobile Ads Unity Plugin v6.0.0
  • (Optional) Google Mobile Ads Unity Plugin v5.4.0.90
    • Contains Native Ads Advanced (Unified) functions

Requirements

  • Unity 2020 (LTS) and above.
  • Google Mobile Ads Unity Plugin v6.0.0
  • (Optional) Native ads build of the Unity plugin.
    • Require native ads build of the Google Mobile Ads Unity plugin to support Native Ads Advanced.
  • Mediation Test Suite plugin.
    • Currently Google Mobile Ads Mediation Test Suite does not support Google Mobile Ads Unity Plugin v6.0.0

Installation

  1. Download and Import Package.
  2. Adding an Ads Object to the scene.

2021-06-02-142858

Interface

  • Banner
  • Interstitial
  • Rewarded
  • Rewarded interstitial

image

  • (Optional) Native Ads Advanced (Unified)

image

Example Code

  • Manually request ads.
CTJ.Ads.Instance.RequestBanner();
CTJ.Ads.Instance.RequestInterstitial();
CTJ.Ads.Instance.RequestRewarded();
CTJ.Ads.Instance.RequestRewardedInterstitial();
CTJ.Ads.Instance.RequestNative(); // Optional
CTJ.Ads.Instance.ForceRequestNative(); // Optional
  • Show ads.
CTJ.Ads.Instance.ShowBannerAd();
CTJ.Ads.Instance.ShowInterstitialAd();
CTJ.Ads.Instance.ShowRewardedAd();
CTJ.Ads.Instance.ShowRewardedInterstitialAd();
CTJ.Ads.Instance.ShowMediationTestSuite(); // Optional
  • Destroy ads.
CTJ.Ads.Instance.DestroyBannerAd();
CTJ.Ads.Instance.DestroyInterstitialAd();
CTJ.Ads.Instance.DestroyUnifiedNativeAd(); // Optional
  • (Optional) Initialize native ads.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Demo : MonoBehaviour
{
    [SerializeField] private GameObject _NativeObject;
    [SerializeField] private GameObject _AdChoicesLogo;
    [SerializeField] private GameObject _Advertiser;
    [SerializeField] private GameObject _Body;
    [SerializeField] private GameObject _CallToAction;
    [SerializeField] private GameObject _Headline;
    [SerializeField] private GameObject _Icon;

    private void Start()
    {
        _NativeObject.SetActive(false);
        CTJ.Ads.Instance.EventAddListener_NativeInitialize(DemoNativeInitialize);
    }

    public void DemoNativeInitialize()
    {
        _AdChoicesLogo.GetComponent<RawImage>().texture = CTJ.Ads.Instance.GetAdChoicesLogo;
        _Advertiser.GetComponent<Text>().text = CTJ.Ads.Instance.GetAdvertiser;
        _Body.GetComponent<Text>().text = CTJ.Ads.Instance.GetBody;
        _CallToAction.GetComponent<Text>().text = CTJ.Ads.Instance.GetCallToAction;
        _Headline.GetComponent<Text>().text = CTJ.Ads.Instance.GetHeadline;
        _Icon.GetComponent<RawImage>().texture = CTJ.Ads.Instance.GetIcon;
        CTJ.Ads.Instance.RegisterAdChoicesLogo(_AdChoicesLogo);
        CTJ.Ads.Instance.RegisterAdvertiser(_Advertiser);
        CTJ.Ads.Instance.RegisterBody(_Body);
        CTJ.Ads.Instance.RegisterCallToAction(_CallToAction);
        CTJ.Ads.Instance.RegisterHeadline(_Headline);
        CTJ.Ads.Instance.RegisterIcon(_Icon);
        _NativeObject.SetActive(true);
    }
}

googleads-mobile-unity-example's People

Contributors

christjie avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

googleads-mobile-unity-example's Issues

應用程式閃退問題

根據以下插件更新有關:
com.google.android.gms.play-services-ads-20.0.0.aar
com.google.android.gms.play-services-ads-base-20.0.0.aar
com.google.android.gms.play-services-ads-lite-20.0.0.aar
com.google.android.gms.play-services-gass-20.0.0.aar

可能建置錯誤相關插件:
com.google.android.gms.play-services-tasks.aar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.