DefUnityAds. Video ADS native extension


#1

UnityAds native extension for Defold engine.
Example and documentation avaliable by link:

Installation

You can use the DefUnityAds extension in your own project by adding this project as a Defold library dependency.
Open your game.project file and in the dependencies field under project add:

https://github.com/AGulev/DefUnityAds/archive/master.zip

Android installation info

Set defunityads/AndroindManifest.xml as default manifest for your project or add the next Activities to your manifest:

<!-- For DefUnityAds -->
<activity
android:name="com.unity3d.ads.adunit.AdUnitActivity"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
android:hardwareAccelerated="true"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />
<activity
android:name="com.unity3d.ads.adunit.AdUnitSoftwareActivity"
android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen"
android:hardwareAccelerated="false"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" />

Known issues:

  • I could not find anybody who use getPlacementState method - and it was not implemented into the extension. If you use/need this method just give me know.

It’s my first native extension. I’ll happy any feedback. Thanks!

UPD: iOS and Android are supported.


Bring Me Cakes. Red Riding Hood Puzzle
#2

Nice! Thanks for shaing!


#3

Fantastic! Thank you for sharing!


#4

Just made first update - removed one unneed delegate.

And I found an issue with “Sign IOS App…” maybe @sven or @britzl know what it can be?
Issue:

  • I install “Sign IOS App…” dmengine to my ipad;
  • change example project - made an unityads.initialization in init() method of script;
  • cmd+b example project;
  • it will initialized but when I tap to show ad - it doesn’t show. Looks like it shows somewhere in background.
    I have no this issue in the bundle build. And all fine when I made unityads.initialization in other place (not in init method)

Do you know what can it be?


#5

I have no idea to be honest. @sven or @Mathias_Westerdahl probably knows though.


#6

As I understand something happen with main view and it happen after lua init methods in scripts.

When I try to add next code to show method - ad works good.

    UIView *view = dmGraphics::GetNativeiOSUIView();
    unityAds.view.bounds = view.bounds;
    [view addSubview:unityAds.view];

Looks like nativeiosview remove all chield view or something like this. But I don’t understand why it happen after init methods…


#7

Now, when bug with UIWindow (1.2.103) fixed, i have one more question.

As I understand, Unity Ads delegate should be a UIViewController.
I adding this view to scene next way (using app UIView that I recieve using GetNativeiOSUIView()):

   UIView *view = dmGraphics::GetNativeiOSUIView();
    unityAds = [[DefUnityAdsDelegate alloc] init];
    unityAds.view.bounds = view.bounds;
    [view addSubview:unityAds.view];

I am bad in IOS, maybe somebody know… Now when we have UIWindow, should I change this code? And add the view to application view hierarchy some other way?

(prev question about init method and UIView initialization when i use dmengine still opened. And maybe the answer to this question will help with the previous one)
Thank you!


#8

DefUnityAds updated.
Now it support android too.


#9

Amazing! Well done!


#10

I just updated DefUnityAds. Now it is more stable.
The problem was in async callbacks in another thread and it was a cause of app crash in some cases on Android.

Now this problem solved. Pls update DefUnityAds, especially if you build android apk.


#11

I made a commit with a stability improvements on android, thanks for the bug report @jouni.petteri.pekone

I am happy that somebody use DefUnityAds! :joy_cat:


#12

Just integrated this into my own project. I think it took 30 minutes tops to get it working on device! Great work :smiley:


#13

Agreed, just deploy Free game build with DefUnityAds - easy to use and good working. Good library from good dev.


#14

Thank you for kind words.

I made a small DefUnityAds update:

  • Unity Ads lib updated to version 2.1.1;
  • extension now working with dmengine and multiple run of project;
  • added debug logs for unsopported platforms (macos, windows etc).

#15

It seems to crash if you run dmengine 1.2.114 and iOS 11.0.2 at least. No idea why, just wanted to report it.


#16

Thank you for the report. I’ll try to fix.


#17

Small update:


#18

One more small update:

  • Unity Ads lib updated to version 2.1.2.