- Home /
iAd in Unity 1.7
Hey,
i'm trying to put iAd into my unity 1.7 basic game all my forum searches yeild that there's a plug in for unity 3, but i want to get iad running on my game in the curent stable release of 1.7.
i'm trying to follow the instructions in the iAd programming guide by apple and i don't really understand objc and whats' goign on enough to do it. there's something about attaching it to a view when i try to put the code in the AppController :
ADBannerView *adView = [[ADBannerView alloc] initWithFrame:CGRectZero];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50; [self.view addSubview:adView];
i get a compile error: 2.6.1/Classes/../../Assets/Editor/OpenFeint/Xcode/AppController+OpenFeint.mm:658: error: request for member 'view' in 'self', which is of non-class type 'AppController*'
can anyone help? does anyone have a running code for 1.7 basic that they can share?
AppController is not actually a view controller, it creates one at runtime so self.view does not exist because self is an instance of AppController which is a child of NSObject, not ViewController. You need to find the instance of ViewController and add a subview to that.
After a LITTLE poking around, it appears that the player just adds the Unity view directly to the Window in the OpenEAGL_UnityCallback method. Now, that is just from looking over the file and picking out some things so I can't guarantee it.
ok - so how do i access the unity view from the openfeint appcontroller?
It's tricky. I would look at this page for some guidance. http://technology.blurst.com/a-cocoa-based-frontend-for-unity-iphone-applications/
Answer by Baby Ninja Developer · Nov 16, 2010 at 06:40 AM
Condition is getting no error message after installation (buid->append) and patching! In my case OF was installed before and was running good.
If you are working with OF and the iAd Plugin in Unity... a easy solution to run OF and iAd you can do following steps:
-Uncomment in AppController.mm the header file like this:
//#import "InGameAdViewController.h"
-Uncomment in AppController.mm Function applicationDidFinishLaunching:(UIApplication*)application like this:
printf_console("-> applicationDidFinishLaunching() AppController.mm\n");
[self startUnity:application];
//adViewController = [[InGameAdViewController alloc] init];
//adViewController.appController = self;
//UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
//[keyWindow addSubview:adViewController.view];
//[keyWindow bringSubviewToFront:adViewController.view];
-Copy the uncommented 5 lines above
-Go to AppController+OpenFeint.mm and import the header file like this:
#import "InGameAdViewController.h"
-Go to Function didFinishLaunchingWithOptions (in AppController+OpenFeint.mm)
-Paste the copied lines before and it should run
In my case it works now
My Software: OF2.6 | Unity iPhone Prof 1.7 | iAd Plugin 1.6.1 | Base SDK 4.1 | Targeting 3.2
Attention, i think it don`t work on iPad, there come a error, so if you design for both devices you must weak against the framework iAd.framework
Hope it helps anybody!!!
Your answer
Follow this Question
Related Questions
iOS iAd causing hiccups on load 1 Answer
Attempt at using plugins for iphone 0 Answers
How do I enable iAds on my unity game for iPhone? 0 Answers
Transparent background 2 Answers
Mix native Objective-C code and Unity3d 0 Answers