DefVideoAds (plugin for Unity ADS). Video ADS native extension


#1

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


https://www.defold.com/community/projects/65114/

Installation

You can use the DefVideoAds 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/DefVideoAds/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 DefVideoAds -->
<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" />

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

UPD: iOS and Android are supported.


Poll for a next Lib/NE
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.

#19

New one update:

  • Unity ADS lib updated to 2.2 (still have no documentation for new api methods. For now it just lib update)

  • Few fix for android integration (was deleted local JNI references for java variables)

UPD:

Finally released DefUnityADS 1.0.0

NEW: added unityads.getPlacementState()

UPD 1.0.1 :
Unity ADS SDK was updated to latest version (2.2.1)
New version may crash on iOS (this is bug of original Unity sdk, not mine) if you try to show ads before initialization. Be careful and use isReady() method before Show() (without parameters) .

UPD 1.1.1 :
UnityAds plugin has strange crash in iOS 11.3.1 - isReady() and show() and getPlacementState() method doesn’t work without placementId parameter. I’ll try to understand what’s wrong with my code in new ios, but for now I made a hotfix. Now you receive a lua error (without crash) when you try to use isReady() or show() without placementId.
Thanks @karawra for the report and @Dragosha for helping with testing (i have no needed device)!

UPD 1.2.0 :
Fixed bug with isReady(), show(), getPlacementState() without placementId parameter. You can use those methods with defaults parameter again.
Fixed bug with UnityAds, when you try to call show() before sdk initialisation.


#20

I’m going to soon test using DefUnityAds exclusively for rewarded video monetization on a project for iOS/Android.