-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from AGulev/unity-3-4-2
Unity 3.4.2
- Loading branch information
Showing
21 changed files
with
579 additions
and
345 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ _“This plugin is not endorsed or sponsored by Unity Technologies. This is an i | |
# DefVideoAds (plugin for Unity ADS) | ||
|
||
This is [UnityAds](https://unity3d.com/ru/services/ads) native extension for [Defold engine](http://www.defold.com). | ||
Extension supported IOS and Android. | ||
Extension supported IOS (minimum iOS version is 9.0) and Android. | ||
|
||
## Installation | ||
|
||
|
@@ -24,6 +24,7 @@ See the [example folder](https://github.com/AGulev/DefVideoAds/tree/master/examp | |
|
||
|
||
## LUA Api | ||
Please, read [Android API docs](https://docs.unity3d.com/Packages/[email protected]/manual/MonetizationResourcesApiAndroid.html) and [iOS API docs](https://docs.unity3d.com/Packages/[email protected]/manual/MonetizationResourcesApiIos.html) | ||
### Methods | ||
#### unityads.initialize(gameID, callback) | ||
#### unityads.initialize(gameID, callback, testMode) | ||
|
@@ -108,8 +109,10 @@ unityads.show() -- show default ad | |
unityads.show("rewardedVideo") -- show rewardedVideo | ||
``` | ||
#### unityads.loadBanner(placementId) | ||
#### unityads.loadBanner(placementId, banner_width, banner_height) | ||
```lua | ||
unityads.loadBanner("banner") -- load banner | ||
unityads.loadBanner("banner") -- load banner, by defaulf width = 320, height = 50 | ||
unityads.loadBanner("banner", 320, 50) -- load banner | ||
``` | ||
#### unityads.unloadBanner() | ||
```lua | ||
|
@@ -135,7 +138,6 @@ unityads.BANNER_POSITION_BOTTOM_LEFT | |
unityads.BANNER_POSITION_BOTTOM_CENTER | ||
unityads.BANNER_POSITION_BOTTOM_RIGHT | ||
unityads.BANNER_POSITION_CENTER | ||
unityads.BANNER_POSITION_NONE | ||
``` | ||
|
||
### Constants | ||
|
@@ -152,6 +154,7 @@ unityads.TYPE_DID_START | |
unityads.TYPE_DID_ERROR | ||
unityads.TYPE_DID_FINISH | ||
unityads.TYPE_BANNER | ||
unityads.TYPE_BANNER_ERROR | ||
``` | ||
##### unityads.TYPE_IS_READY | ||
```lua | ||
|
@@ -173,7 +176,7 @@ end | |
```lua | ||
local function defunityads_callback(self, msg_type, message) | ||
if msg_type == unityads.TYPE_DID_ERROR then | ||
pprint(message) -- message = {state = ERROR_*, message = "string"} | ||
pprint(message) -- message = {error = ERROR_*, message = "string"} | ||
end | ||
end | ||
``` | ||
|
@@ -189,18 +192,24 @@ end | |
```lua | ||
local function defunityads_callback(self, msg_type, message) | ||
if msg_type == unityads.TYPE_BANNER then | ||
if message.event == BANNER_EVENT_DID_ERROR then | ||
pprint(message) -- message = {event = BANNER_EVENT_DID_ERROR, error = "string"} | ||
else | ||
if message.event == BANNER_EVENT_DID_LOAD then | ||
pprint(message) -- message = {event = BANNER_EVENT_*, placementId = "string"} | ||
end | ||
end | ||
end | ||
``` | ||
##### unityads.TYPE_BANNER_ERROR | ||
```lua | ||
local function defunityads_callback(self, msg_type, message) | ||
if msg_type == unityads.TYPE_BANNER_ERROR then | ||
pprint(message) -- message = {error = BANNER_ERROR_*, message = "string"} | ||
end | ||
end | ||
``` | ||
#### Error types | ||
[Original doc about error types](https://github.com/Unity-Technologies/unity-ads-ios/wiki/sdk_ios_api_errors) | ||
```lua | ||
--possible message.error : | ||
--possible message.error for unityads.TYPE_DID_ERROR: | ||
unityads.ERROR_NOT_INITIALIZED --kUnityAdsErrorNotInitialized | ||
unityads.ERROR_INITIALIZED_FAILED --kUnityAdsErrorInitializedFailed | ||
unityads.ERROR_INVALID_ARGUMENT --kUnityAdsErrorInvalidArgument | ||
|
@@ -222,6 +231,25 @@ local function defunityads_callback(self, msg_type, message) | |
end | ||
end | ||
``` | ||
#### Banner error types | ||
[Original doc about error types](https://docs.unity3d.com/Packages/[email protected]/manual/MonetizationResourcesApiAndroid.html#bannerview) | ||
```lua | ||
--possible message.error for unityads.TYPE_BANNER_ERROR: | ||
unityads.BANNER_ERROR_UNKNOWN -- | ||
unityads.BANNER_ERROR_NATIVE | ||
unityads.BANNER_ERROR_WEBVIEW | ||
unityads.BANNER_ERROR_NOFILL | ||
``` | ||
```lua | ||
local function defunityads_callback(self, msg_type, message) | ||
if msg_type == unityads.TYPE_BANNER_ERROR then | ||
if message.error == unityads.BANNER_ERROR_UNKNOWN then | ||
... | ||
elseif message.error == unityads.BANNER_ERROR_NATIVE then | ||
... | ||
end | ||
end | ||
``` | ||
#### Finish states | ||
[Original doc about finish states](https://github.com/Unity-Technologies/unity-ads-ios/wiki/sdk_ios_api_finishstates) | ||
```lua | ||
|
@@ -244,18 +272,15 @@ end | |
```lua | ||
--possible banner events: | ||
unityads.BANNER_EVENT_DID_LOAD | ||
unityads.BANNER_EVENT_DID_UNLOAD | ||
unityads.BANNER_EVENT_DID_SHOW | ||
unityads.BANNER_EVENT_DID_HIDE | ||
unityads.BANNER_EVENT_DID_CLICK | ||
unityads.BANNER_EVENT_DID_ERROR | ||
unityads.BANNER_EVENT_DID_LEAVE_APP | ||
``` | ||
```lua | ||
local function defunityads_callback(self, msg_type, message) | ||
if msg_type == unityads.TYPE_BANNER then | ||
if message.event == unityads.BANNER_EVENT_DID_LOAD then | ||
... | ||
elseif message.event == unityads.BANNER_EVENT_DID_UNLOAD then | ||
elseif message.event == unityads.BANNER_EVENT_DID_CLICK then | ||
... | ||
end | ||
end | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
defunityads/lib/ios/UnityAds.framework/Headers/UADSBannerError.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#import <Foundation/Foundation.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
typedef NS_ENUM(NSInteger, UADSBannerErrorCode) { | ||
UADSBannerErrorCodeUnknown = 0, | ||
UADSBannerErrorCodeNativeError = 1, | ||
UADSBannerErrorCodeWebViewError = 2, | ||
UADSBannerErrorCodeNoFillError = 3 | ||
}; | ||
|
||
@interface UADSBannerError : NSError | ||
|
||
- (instancetype)initWithCode:(UADSBannerErrorCode)code userInfo:(nullable NSDictionary<NSErrorUserInfoKey, id> *)dict; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
19 changes: 19 additions & 0 deletions
19
defunityads/lib/ios/UnityAds.framework/Headers/UADSBannerView.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#import <Foundation/Foundation.h> | ||
#import <UIKit/UIKit.h> | ||
#import "UADSBannerViewDelegate.h" | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface UADSBannerView : UIView | ||
|
||
@property(nonatomic, readonly) CGSize size; | ||
@property(nonatomic, readwrite, nullable, weak) NSObject <UADSBannerViewDelegate> *delegate; | ||
@property(nonatomic, readonly) NSString *placementId; | ||
|
||
-(instancetype)initWithPlacementId:(NSString *)placementId size:(CGSize)size; | ||
|
||
-(void)load; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
40 changes: 40 additions & 0 deletions
40
defunityads/lib/ios/UnityAds.framework/Headers/UADSBannerViewDelegate.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#import <Foundation/Foundation.h> | ||
#import "UADSBannerError.h" | ||
|
||
@class UADSBannerView; | ||
|
||
/** | ||
* UnityAdsBannerDelegate is a delegate class for callbacks from Unity Ads Banner operations. | ||
*/ | ||
@protocol UADSBannerViewDelegate <NSObject> | ||
|
||
@optional | ||
/** | ||
Called when the banner is loaded and ready to be placed in the view hierarchy. | ||
@param bannerView View that was loaded | ||
*/ | ||
- (void)bannerViewDidLoad:(UADSBannerView *)bannerView; | ||
|
||
/** | ||
* Called when the user clicks the banner. | ||
* | ||
* @param bannerView View that the click occurred on. | ||
*/ | ||
- (void)bannerViewDidClick:(UADSBannerView *)bannerView; | ||
|
||
/** | ||
* Called when a banner causes | ||
* @param bannerView View that triggered leaving application | ||
*/ | ||
- (void)bannerViewDidLeaveApplication:(UADSBannerView *)bannerView; | ||
|
||
/** | ||
* Called when `UnityAdsBanner` encounters an error. All errors will be logged but this method can be used as an additional debugging aid. This callback can also be used for collecting statistics from different error scenarios. | ||
* | ||
* @param bannerView View that encountered an error. | ||
* @param error UADSBannerError that occurred | ||
*/ | ||
- (void)bannerViewDidError:(UADSBannerView *)bannerView error:(UADSBannerError *)error; | ||
|
||
@end |
Oops, something went wrong.