插件地址: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. typescript泛型接口

    //函数类型接口 /* interface ConfigFn{ (value1:string,value2:string):string; } var setData:ConfigFn=functio ...

  2. navicat创建存储过程的小问题

    再简单的东西长时间不用了就会出错,特此即时的记录下来,以便以后参考! 转自:http://blog.csdn.net/winy_lm/article/details/49690633 以下为navic ...

  3. 电商系统架构总结3(webapi授权机制)

    三 Web API 授权方式 web api的客户端,包括 android,ios,h5,自然对访问权限要加上授权机制.对于h5,要求把h5站点和web api部署在同一个域名下,然后对web api ...

  4. python脚本参数传递

    环境:python 库:optparse 效果:python  xxx.py  -parameter1  参数1  -parameter2 参数2 .... 废话少说,直接上代码ok?  xxx.py ...

  5. TextView右上角显示小红点,小红点根据TextView的长度移动,小红点被TextView挤出去不显示的问题;

    大概就是图片这个样,这个功能很常见,本来我以为很简单,谁知道真的很简单: 遇到点小问题,记录一下,哈哈: 小红点的Drawable: <?xml version="1.0" ...

  6. vs2017配置文件目录

    C:\Users\Administrator\AppData\Local\Microsoft\VisualStudio\15.0_6d0a0a42

  7. Uncaught (in promise) DOMException: Failed to execute 'open' on 'XMLHttpRequest': Invalid URL

    解决方案:url前面一定要加http://

  8. chattr和lsattr命令的使用(对于root用户也无法修改删除的操作问题)

    1.chattr命令的用法:chattr [+-=] [ASacdistu] File/Directory 参数说明: +-= :分别为 [+ 增加] [- 减少] [= 设定] 属性的意思 A :当 ...

  9. 【Linux】【JDK】常用命令使用集和裸机配置JDK步骤。

    使用Zstack创建完成后的linux服务器,使用SSH登录后,就是一下图,可以查看当前路径下的所有文件. 1.常用的命令: 列出当前文件夹下内容:ll 查看目录中的文件 :ls 创建文件夹:mkdi ...

  10. Oracle 命令

    net start oracleserviceorcl  启动服务 sql>shutdown     关闭数据库 sql>startup         打开数据库 sql> sel ...