插件地址:https://github.com/unity-plugins/Unity-Admob

2017.04.11测试使用发现GoogleMobileAds.framework有问题,导致出现Undefined symbols for architecture等错误


以下是测试过的完整插件包:

链接:http://pan.baidu.com/s/1c1YL1mg 密码:vi8q


无出错的GoogleMobileAds.framework:

链接:http://pan.baidu.com/s/1jHNdXNg 密码:bwyk


unity 版本:5.6.f3

Target minimum iOS Version: 8.0

全屏广告需要在unity发布设置或xcode中把所有方向都勾上,再用代码决定要保留哪些方向,这样手持设备广告的方向才能显示正确


AdmobManager.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using admob; public class AdmobManager : MonoBehaviour {
public string bannerID="ca-app-pub-3940256099942544/2934735716";
public string fullID="ca-app-pub-3940256099942544/4411468910";
public string rewardVideoID="ca-app-pub-3940256099942544/xxxxxxxxxx"; public string nativeBannerID="ca-app-pub-3940256099942544/2562852117"; Admob ad;
private bool _isinited; public static AdmobManager instance {
get{
return GameObject.Find("AdmobManager").GetComponent<AdmobManager>();
}
} void Awake(){
Debug.Log("start unity demo-------------");
gameObject.name="AdmobManager";
initAdmob();
} void Start () { } void Update () {
//ad.showInterstitial();
} void initAdmob(){
//isAdmobInited = true;
ad = Admob.Instance();
ad.bannerEventHandler += onBannerEvent;
ad.interstitialEventHandler += onInterstitialEvent;
ad.rewardedVideoEventHandler += onRewardedVideoEvent;
ad.nativeBannerEventHandler += onNativeBannerEvent;
ad.initAdmob(bannerID,fullID);
//ad.setTesting(true);
ad.setGender(AdmobGender.MALE);
string[] keywords = { "game","crash","male game"};
ad.setKeywords(keywords);
Debug.Log("admob inited -------------");
} void onInterstitialEvent(string eventName, string msg){
Debug.Log("handler onAdmobEvent---" + eventName + " " + msg);
if (eventName == AdmobEvent.onAdLoaded){
Admob.Instance().showInterstitial();
}else if(eventName==AdmobEvent.onAdClosed){
//Admob.Instance().loadInterstitial();
}
}
void onBannerEvent(string eventName, string msg){
Debug.Log("handler onAdmobBannerEvent---" + eventName + " " + msg);
}
void onRewardedVideoEvent(string eventName, string msg){
Debug.Log("handler onRewardedVideoEvent---" + eventName + " " + msg);
}
void onNativeBannerEvent(string eventName, string msg){
Debug.Log("handler onAdmobNativeBannerEvent---" + eventName + " " + msg);
} public bool isInterstitialReady(){
return ad.isInterstitialReady();
}
public void loadInterstitial(){
ad.loadInterstitial();
} public void showInterstitial(){
ad.showInterstitial();
} public void showRewardVideo(){
if (ad.isRewardedVideoReady()) ad.showRewardedVideo();
else ad.loadRewardedVideo(rewardVideoID);
} public void showbanner(AdSize size/*=AdSize.SmartBanner*/, int pos/*=AdPosition.BOTTOM_CENTER*/,int marginY=){
Admob.Instance().showBannerRelative(size, pos,marginY);
}
public void showbannerABS(AdSize size/*=AdSize.Banner*/,int x=,int y=){
Admob.Instance().showBannerAbsolute(size, x, y);
}
public void removebanner(){
Admob.Instance().removeBanner();
} public void showNative(int pos/*=AdPosition.BOTTOM_CENTER*/,int width=,int height=,int marginY=){
Admob.Instance().showNativeBannerRelative(new AdSize(width,height), pos, marginY,nativeBannerID);
}
public void showNativeABS(int width=,int height=,int x=,int y=){
Admob.Instance().showNativeBannerAbsolute(new AdSize(width,height), x, y, nativeBannerID);
}
public void removeNative(){
Admob.Instance().removeNativeBanner();
} }

Editor文件夹下PBXProjectSetting.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.iOS.Xcode; public class PBXProjectSetting{ //该属性是在build完成后,被调用的callback
[PostProcessBuild]
public static void OnPostprocessBuild(BuildTarget buildTarget, string path){
// BuildTarget需为iOS
if (buildTarget != BuildTarget.iOS) return;
Debug.Log("===PostProcessBuildAttribute();==="); string projPath = PBXProject.GetPBXProjectPath(path);
PBXProject pbxProject = new PBXProject(); pbxProject.ReadFromString(File.ReadAllText(projPath));
string target = pbxProject.TargetGuidByName("Unity-iPhone"); // 关闭Bitcode
pbxProject.SetBuildProperty(target, "ENABLE_BITCODE", "NO"); // 添加framework, admob需要的所有framework
pbxProject.AddFrameworkToProject(target, "AdSupport.framework", false);
pbxProject.AddFrameworkToProject(target, "EventKit.framework", false);
pbxProject.AddFrameworkToProject(target, "EventKitUI.framework", false);
pbxProject.AddFrameworkToProject(target, "CoreTelephony.framework", false);
pbxProject.AddFrameworkToProject(target, "StoreKit.framework", false);
pbxProject.AddFrameworkToProject(target, "MessageUI.framework", false); //保存到本地
File.WriteAllText(projPath,pbxProject.WriteToString());
}
}

unity admob的更多相关文章

  1. Unity3D添加Admob广告

    重要提示:             貌似play2014年8月之后不会再支持admob的SDK方式的广告了.github上已经有了 Unity AdMob (Google Play Services) ...

  2. Unity3d开发集成Google Admob广告增加收入

    在Unity游戏中植入广告是Unity 游戏产品增加收入的一种重要方式,常用的广告有谷歌Admob,百度ssp,腾讯广点通,unity公司的unityads等等,而使用的最多的应该属于谷歌Admob, ...

  3. unity接入谷歌ADMob注意事项

    应用不显示广告,可能是广告sdk 依赖项没有注册 dependencies { implementation fileTree(dir: 'bin', include: ['*.jar']) impl ...

  4. 【Unity与Android】02-在Unity导出的Android工程中接入Google Admob广告

    我在上一篇文章 [Unity与Android]01-Unity与Android交互通信的简易实现) 中介绍了Unity与Android通讯的基本方法. 这一篇开始进入应用阶段,这次要介绍的是如何在An ...

  5. Unity3D IOS IPhone添加Admob的方法

    原地址:http://dong2008hong.blog.163.com/blog/static/4696882720140403119293/ 首先阅读官方文档https://developers. ...

  6. Unity3d Android程序嵌入Admob广告条

    原地址:http://dong2008hong.blog.163.com/blog/static/4696882720140441353482/ Seems like using a simple A ...

  7. 2017年Unity游戏开发视频教程(入门到精通)

    本文是我发布的一个Unity游戏开发的学习目录,以后我会持续发布一系列的游戏开发教程,都会更新在这个页面上,适合人群有下面的几种: 想要做独立游戏的人 想要找游戏开发相关工作的人 对游戏开发感兴趣的人 ...

  8. iOS平台添加Google Admob -1/2(Unity3D开发之七)

    猴子原创,欢迎转载.转载请注明: 转载自Cocos2D开发网–Cocos2Dev.com,谢谢! 原文地址: http://www.cocos2dev.com/?p=567 Unity调用iOS还是非 ...

  9. iOS平台添加Google Admob -2/2(Unity3D开发之八)

    猴子原创,欢迎转载.转载请注明: 转载自Cocos2D开发网–Cocos2Dev.com,谢谢! 原文地址: http://www.cocos2dev.com/?p=572 在上一篇文章中主要是编写了 ...

随机推荐

  1. T-SQL 事务2

    启用事务完成转账存储过程 use StudentManager go if exists(select * from sysobjects where name='usp_TransferAccoun ...

  2. (转)Linux netstat命令详解

    简介 Netstat 命令用于显示各种网络相关信息,如网络连接,路由表,接口状态 (Interface Statistics),masquerade 连接,多播成员 (Multicast Member ...

  3. CS229 6.2 Neurons Networks Backpropagation Algorithm

    今天得主题是BP算法.大规模的神经网络可以使用batch gradient descent算法求解,也可以使用 stochastic gradient descent 算法,求解的关键问题在于求得每层 ...

  4. 浅析Redis 和MongoDB

    今天来聊聊什么事nosql,一听nosql也许很多人会觉得很高大上的感觉,但其实接触过了也还觉得还行,随着当今数据的疯狂爆炸性的增长,传统的RDBMS也越来越暴露出他的不足之处,所以,作为一名合格的程 ...

  5. 【Fiddler学习】Fiddler简介和Web抓包应用(转)

    一.Fiddler是什么? Fiddler是一个http协议调试代理工具,它能够记录并检查所有你的电脑和互联网之间的http通讯,设置断点,查看所有的进出Fiddler的数据. Fiddler 要比其 ...

  6. android_自定义布局例子

    为什么要写自定义布局: 1.在实现大量重复的子按键或者子布局时,如果一个一个去复写工作量庞大,就需要创建自定义布局直接导入布局里,可以节省大量的时间 创建自定义布局的步骤: 1.编写一个自定义xml布 ...

  7. [UGUI]滑动列表优化(循环利用)

    需要注意的有下面几点: 1. 区分好表现上的index和逻辑上的index.表现上的index是指这个go是go列表中的第几项,但实际上这个index的意义并不大,因为在滚动的过程中go列表是轮转的: ...

  8. 本地计算机上的OracleDBConsoleorcl服务启动后停止

    emca -repos dropemca -repos createemca -config dbcontrol db 这三步你都运行成功了也没有报错?最后没有提示你dbcontrol已经启动了么?, ...

  9. Maintenance Planner calculate SPs by manual

    note Are you unable to view your system or updated system information? Apply the latest version of t ...

  10. 55.纯 CSS 创作一个太阳、地球、月亮的运转模型

    原文地址:https://segmentfault.com/a/1190000015313341 感想:主要运用边框.伪元素.动画. HTML code: <div class="co ...