This post is for beginners and I will teach how to create a simple Android plugin for Unity3D. This plugin will show admob on your app.
In a futher post I will show how to use AndroidJNI for callbacks from C# to Java code inside on your plugin.
First, on your Unity environment create a folder named Plugins and a subfolder named Android. This is default. Inside Android's folder we will create the android project from eclipse.
In a futher post I will show how to use AndroidJNI for callbacks from C# to Java code inside on your plugin.
First, on your Unity environment create a folder named Plugins and a subfolder named Android. This is default. Inside Android's folder we will create the android project from eclipse.
Now create a Android Project on Eclipse.
Change the default location to your Android folder on Unity |
Setup the package name with care and choose the min SDK version. |
Create a folder named libs and paste the admob library |
Add the library admob from your worspace and the Unity library from the Editor's folder. Add the Classes.jar |
Don't forget to select all libraries to export. |
And select the compilance level to 1.5 |
Select the app target over 3.0 O target |
manifest.xml
to add permissions and other configurations. You may see this steps on: https://developers.google.com/mobile-ads-sdk/docs/admob/fundamentalsNow, let's code the Admob!
Agora você só precisar configurar seu admob exatamente como mostra no site da Google |
The main activity is extended from
UnityPlayerActivity
. This override the main class of Unity and does your plugin the start point of your app.This code is to add a Layer on default 3D view. The linear layout will receive the admob.
Now,
Clean
your project and Export
; it!Now you can do the build from Unity3D and remember to adjust the package name on
Build Settings
to the same of your plugin.You can download the projet here.
Nenhum comentário:
Postar um comentário