1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Unity バナー広告を付ける

Posted at

手順

GameIDの発行
Unity Cloudへログインし

https://cloud.unity.com/
ダッシュボード
image.png

広告を使いたいプロジェクトを選ぶ
image.png
シュートカットからUnityAdsを選んで
image.png
GetStarted
image.png
UniytでAndroidなら以下の選択
image.png

image.png

image.png
すでにリリースしているならそのURLを張る
image.png

これでGameIDが発行される
image.png

実行するにはテストモードにリリースするときに解除すること
Unity Ads Monetization の設定から
image.png
一番下のテストモードを変更
image.png
image.png

ADS Packagesのインストール

Pacage Managerから
Ads mediation
Advertisement Legacyをインストール
image.png

スクリプトで実装

using UnityEngine.Advertisements;
[SerializeField] string _androidAdUnitId = "生成したID";
void Start()
{
    //バナーの位置
    Advertisement.Banner.SetPosition(BannerPosition.TOP_CENTER);
    Advertisement.Banner.Load(_androidAdUnitId);
}
//適当なボタンで実行させる
public void ShowBannerAd()
{

    Advertisement.Banner.Show(_androidAdUnitId);
}

これを適当なボタンで実行させるとバナーが表示される
Animation.gif

もう少し詳しく

公式のドキュメントにAndroid、IOSのID切り替えと広告が読み込まれなかった時に呼ばれるコールバックの設定があるので基本的にはこれを参考にすること

ここまでくればもうできるはず。やったね。

参考サイト

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?