Skip to content

Commit

Permalink
Merge pull request #5 from AGulev/refactoring
Browse files Browse the repository at this point in the history
Refactoring
  • Loading branch information
AGulev authored Jun 15, 2019
2 parents 91648f6 + 063b608 commit c06abd9
Show file tree
Hide file tree
Showing 18 changed files with 474 additions and 438 deletions.
16 changes: 0 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,6 @@ 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:
```xml
<!-- 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" />
```

## Example

See the [example folder](https://github.com/AGulev/DefVideoAds/tree/master/example) for understand how to use extension. Especially [ui.gui_script](https://github.com/AGulev/DefVideoAds/blob/master/example/ui.gui_script) file.
Expand Down
142 changes: 0 additions & 142 deletions defunityads/AndroidManifest.xml

This file was deleted.

144 changes: 144 additions & 0 deletions defunityads/api/DefUnityAds.script_api
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
- name: unityads
type: table
desc: Functions and constants for interacting with UnityAds APIs

members:

#*****************************************************************************************************

- name: initialize
type: function

parameters:
- name: gameId
type: table

- name: callback
type: function
parameters:
- name: self
type: object

- name: msg_type
type: string

- name: message
type: table

- name: testMode
type: table

#*****************************************************************************************************

- name: setCallback
type: function

parameters:
- name: callback
type: function

#*****************************************************************************************************

- name: setDebugMode
type: function

parameters:
- name: isDebug
type: boolean

#*****************************************************************************************************

- name: getDebugMode
type: function

#*****************************************************************************************************

- name: getPlacementState
type: function

parameters:
- name: placementId
type: string

#*****************************************************************************************************

- name: isReady
type: function

parameters:
- name: placementId
type: string

#*****************************************************************************************************

- name: isInitialized
type: function

#*****************************************************************************************************

- name: isSupported
type: function

#*****************************************************************************************************

- name: getVersion
type: function

#*****************************************************************************************************

- name: show
type: function

parameters:
- name: placementId
type: string

#*****************************************************************************************************

- name: TYPE_IS_READY
type: number

- name: TYPE_DID_START
type: number

- name: TYPE_DID_ERROR
type: number

- name: TYPE_DID_FINISH
type: number


#*****************************************************************************************************

- name: ERROR_NOT_INITIALIZED
type: number

- name: ERROR_INITIALIZED_FAILED
type: number

- name: ERROR_INVALID_ARGUMENT
type: number

- name: ERROR_VIDEO_PLAYER
type: number

- name: ERROR_INIT_SANITY_CHECK_FAIL
type: number

- name: ERROR_AD_BLOCKER_DETECTED
type: number

- name: ERROR_FILE_IO
type: number

- name: ERROR_DEVICE_ID
type: number

- name: ERROR_SHOW
type: number

- name: ERROR_INTERNAL
type: number


#*****************************************************************************************************
4 changes: 4 additions & 0 deletions defunityads/ext.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@ platforms:
armv7-ios:
context:
frameworks: ["AVFoundation", "CoreMedia", "UIKit"]

x86_64-ios:
context:
frameworks: ["AVFoundation", "CoreMedia", "UIKit"]
20 changes: 20 additions & 0 deletions defunityads/manifests/android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- BEGIN_INCLUDE(manifest) -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>

<!-- 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" />

</application>
</manifest>
<!-- END_INCLUDE(manifest) -->
14 changes: 8 additions & 6 deletions defunityads/src/DefUnityAds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@

#if defined(DM_PLATFORM_IOS) || defined(DM_PLATFORM_ANDROID)
#include "utils/LuaUtils.h"
#include "DefUnityCallback.h"
#include "DefUnityAds.h"
#include "private_DefUnityCallback.h"
#include "private_DefUnityAds.h"

static int Initialize(lua_State* L) {
const char *gameId_lua = luaL_checkstring(L, 1);
bool enableDebugMode_lua = false;
set_callback(L, 2);
DefUnityCallback_set_callback(L, 2);
if (lua_type(L, 3) != LUA_TNONE) {
enableDebugMode_lua = luaL_checkbool(L, 3);
}
Expand All @@ -22,7 +22,7 @@ static int Initialize(lua_State* L) {
}

static int setCallback(lua_State* L) {
set_callback(L, 1);
DefUnityCallback_set_callback(L, 1);
return 0;
}

Expand Down Expand Up @@ -148,6 +148,8 @@ dmExtension::Result AppInitializeUnityAds(dmExtension::AppParams* params)
dmExtension::Result InitializeUnityAds(dmExtension::Params* params)
{
LuaInit(params->m_L);
DefUnityAds_InitExtension();
DefUnityCallback_initialize();
return dmExtension::RESULT_OK;
}

Expand All @@ -158,13 +160,13 @@ dmExtension::Result AppFinalizeUnityAds(dmExtension::AppParams* params)

dmExtension::Result FinalizeUnityAds(dmExtension::Params* params)
{
finalize();
DefUnityCallback_finalize();
return dmExtension::RESULT_OK;
}

static dmExtension::Result UpdateUnityAds(dmExtension::Params* params)
{
callback_updates();
DefUnityCallback_callback_updates();
return dmExtension::RESULT_OK;
}

Expand Down
Loading

0 comments on commit c06abd9

Please sign in to comment.