All Projects → AGulev → DefVideoAds

AGulev / DefVideoAds

Licence: Apache-2.0 License
UnityAds native extension for Defold engine.

Programming Languages

objective c
16641 projects - #2 most used programming language
C++
36643 projects - #6 most used programming language
Objective-C++
1391 projects
lua
6591 projects
java
68154 projects - #9 most used programming language
c
50402 projects - #5 most used programming language

Projects that are alternatives of or similar to DefVideoAds

defold-eva
Basic defold module for mobile games
Stars: ✭ 21 (-43.24%)
Mutual labels:  defold-game-engine, defold, defold-module, defold-library
drawpixels
Defold engine native extension for drawing pixels into texture buffer.
Stars: ✭ 46 (+24.32%)
Mutual labels:  defold-game-engine, defold, defold-module, defold-library
extension-fbinstant
Facebook Instant Games extension for the Defold game engine
Stars: ✭ 39 (+5.41%)
Mutual labels:  defold-game-engine, defold, defold-library
DAABBCC
Dynamic AABB Tree native extension with Branch and Bound Algorithm for Defold Engine
Stars: ✭ 42 (+13.51%)
Mutual labels:  defold-game-engine, defold, defold-library
defold-playable-ads
Make playable ads with Defold! It's a project with Gulp tasks to bundle the Defold game into a single HTML file.
Stars: ✭ 15 (-59.46%)
Mutual labels:  defold-game-engine, defold, defold-library
jstodef
Library for sending messages from JavaScript to Defold (Lua)
Stars: ✭ 21 (-43.24%)
Mutual labels:  defold-game-engine, defold, defold-library
defos
Extra native OS functions for games written using the Defold game engine
Stars: ✭ 64 (+72.97%)
Mutual labels:  defold-game-engine, defold, defold-library
defold-hyper-trails
Easy to use and customizable trail effect for the Defold game engine.
Stars: ✭ 33 (-10.81%)
Mutual labels:  defold-game-engine, defold, defold-library
platypus
Defold platformer engine
Stars: ✭ 31 (-16.22%)
Mutual labels:  defold, defold-library
defpro
Defold Profiler interaction using Lua
Stars: ✭ 19 (-48.65%)
Mutual labels:  defold, defold-library
extension-gpgs
Defold native extension for Google Play Game Services
Stars: ✭ 19 (-48.65%)
Mutual labels:  defold, defold-library
gooey
Defold GUI system
Stars: ✭ 99 (+167.57%)
Mutual labels:  defold, defold-library
defnet
Defold networking examples
Stars: ✭ 52 (+40.54%)
Mutual labels:  defold, defold-library
defold-input
Simplify input related operations such as gesture detection, input mapping and clicking/dragging game objects
Stars: ✭ 67 (+81.08%)
Mutual labels:  defold, defold-library
defold-deployer
Universal build && deploy script for Defold projects
Stars: ✭ 23 (-37.84%)
Mutual labels:  defold-game-engine, defold
defold-metrics
Calculate and display performance metrics in Defold games
Stars: ✭ 23 (-37.84%)
Mutual labels:  defold, defold-library
defold-sharing
Defold native extension to share data from a Defold application using native dialogs
Stars: ✭ 20 (-45.95%)
Mutual labels:  defold, defold-library
defold-richtext
Defold-RichText is a system to create styled text based on an HTML inspired markup language
Stars: ✭ 35 (-5.41%)
Mutual labels:  defold, defold-library
extension-admob
Defold native extension which provides access to AdMob functionality on Android and iOS
Stars: ✭ 31 (-16.22%)
Mutual labels:  defold, defold-library
defold-router
whDefRouter — screen management solution for Defold Game Engine (includes demo project)
Stars: ✭ 25 (-32.43%)
Mutual labels:  defold-game-engine, defold

“This plugin is not endorsed or sponsored by Unity Technologies. This is an independent, unofficial plugin. UNITY and the Unity logo are Unity Technologies’ registered trademarks in the US and other countries--All rights reserved.“

defvideoads-01

Build Status

DefVideoAds (plugin for Unity ADS)

This is UnityAds native extension for Defold engine. Extension supported IOS (minimum iOS version is 9.0) and Android.

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

or point to the ZIP file of a specific release.

Minimum SDK version in game.project->Android should be 19 or above.

image

Example

See the example folder for understand how to use extension. Especially ui.gui_script file.

Example

LUA Api

Please, read Android API docs and iOS API docs

Methods

unityads.request_idfa()

unityads.request_idfa()
-- iOS only method that shows IDFA request popup.
-- On Android it always fire callback with MSG_IDFA/EVENT_NOT_SUPPORTED
-- should be called before initialization

unityads.initialize(game_id, callback)

unityads.initialize(game_id, callback, test_mode)

Original Docs iOS Android

local function defunityads_callback(self, message_id, message)
...
end
...
unityads.initialize("1401815", defunityads_callback)
 -- `test_mode` is optional parameter:
unityads.initialize("1401815", defunityads_callback, true)

unityads.set_callback(callback)

unityads.set_callback(defunityads_callback) -- set callback
unityads.set_callback(nil) -- remove callback
unityads.set_callback() -- remove callback

unityads.set_debug_mode(is_debug)

Original Docs iOS Android

unityads.set_debug_mode(true) -- set debug mode
unityads.set_debug_mode(false) -- set debug mode

unityads.get_debug_mode()

Original Docs iOS Android

local is_debig_mode = unityads.getDebugMode() -- Returns true if current mod is debug

unityads.is_initialized()

Original Docs iOS Android

local is_initialized = unityads.is_initialized() -- Returns `true` if Unity ADS initialized

unityads.is_supported()

Original Docs iOS Android

local is_supported = unityads.is_supported() -- Returns `true` if Unity Ads is supported by the current device

unityads.get_version()

local version = unityads.get_version() -- Returns the Unity Ads SDK version as a string.

unityads.show(placement_id)

unityads.show("rewardedVideo") -- show rewardedVideo

unityads.load(placement_id)

unityads.load("rewardedVideo") -- load rewardedVideo

unityads.load_banner(placement_id)

unityads.load_banner(placement_id, banner_width, banner_height)

unityads.load_banner("banner") -- load banner, by defaulf width = 320, height = 50
unityads.load_banner("banner", 320, 50) -- load banner

unityads.unload_banner()

unityads.unload_banner() -- unload banner

unityads.show_banner()

unityads.show_banner() -- show banner

unityads.hide_banner()

unityads.hide_banner() -- hide banner

unityads.set_banner_position(position)

unityads.set_banner_position(position) -- set position of the banner
-- default value is unityads.BANNER_POSITION_TOP_CENTER

--possible positions:
unityads.BANNER_POSITION_TOP_LEFT
unityads.BANNER_POSITION_TOP_CENTER
unityads.BANNER_POSITION_TOP_RIGHT
unityads.BANNER_POSITION_BOTTOM_LEFT
unityads.BANNER_POSITION_BOTTOM_CENTER
unityads.BANNER_POSITION_BOTTOM_RIGHT
unityads.BANNER_POSITION_CENTER

Constants

local function defunityads_callback(self, message_id, message)
...
end

Message types

--possible values for `message_id` :
unityads.MSG_INIT
unityads.MSG_SHOW
unityads.MSG_LOAD
unityads.MSG_BANNER
unityads.MSG_IDFA
unityads.MSG_INIT
local function defunityads_callback(self, message_id, message)
  if message_id == unityads.MSG_INIT then
    if message.event == unityads.EVENT_COMPLETED then
        -- message = {placement_id = "string", ...}
    elseif message.event == unityads.EVENT_SDK_ERROR then
        -- message = {code = int, error = "error message string"}
        if message.code == unityads.ERROR_INTERNAL then
            -- initialization failed due to environment or internal services
        elseif message.code == unityads.ERROR_INVALID_ARGUMENT then
            -- initialization failed due to invalid argument(e.g. game ID)
        elseif message.code == unityads.ERROR_AD_BLOCKER_DETECTED then
            -- initialization failed due to url being blocked
        end
    elseif message.event == unityads.EVENT_JSON_ERROR then
        -- message = {error = "error message string"}
    end
  end
end
unityads.MSG_SHOW
local function defunityads_callback(self, message_id, message)
  if message_id == unityads.MSG_SHOW then
    if message.event == unityads.EVENT_COMPLETED then
      -- message = {placement_id = "string"}
      -- An event that indicates that the ad was played entirely.
    elseif message.event == unityads.EVENT_SKIPPED then
        -- message = {placement_id = "string"}
        -- An event that indicates that the user skipped the ad.
    elseif message.event == unityads.EVENT_START then
        -- message = {placement_id = "string"}
        -- UnityAds has started to show ad with a specific placement.
    elseif message.event == unityads.EVENT_CLICKED then
        -- message = {placement_id = "string"}
        -- UnityAds has received a click while showing ad with a specific placement.
    elseif message.event == unityads.EVENT_SDK_ERROR then
        -- message = {code = int, error = "error message string", placement_id = "string"}
        if message.code == unityads.ERROR_NOT_INITIALIZED then
            -- show failed due to SDK not initialized.
        elseif message.code == unityads.ERROR_NOT_READY then
            --show failed due to placement not being ready.
        elseif message.code == unityads.ERROR_VIDEO_PLAYER then
            -- show failed due to video player.
        elseif message.code == unityads.ERROR_INVALID_ARGUMENT then
            -- show failed due to invalid arguments.
        elseif message.code == unityads.ERROR_NO_CONNECTION then
            -- show failed due to internet connection.
        elseif message.code == unityads.ERROR_ALREADY_SHOWING then
            -- show failed due to ad is already being showen.
        elseif message.code == unityads.ERROR_INTERNAL then
            -- show failed due to environment or internal services.
        end
    elseif message.event == unityads.EVENT_JSON_ERROR then
        -- message = {error = "error message string"}
    end
  end
end
unityads.MSG_LOAD
local function defunityads_callback(self, message_id, message)
  if message.event == unityads.EVENT_LOADED then
      -- message = {placement_id = "string"}
      -- Load request has successfully filled the specified placementId with an ad that is ready to show.
  elseif message.event == unityads.EVENT_SDK_ERROR then
      -- message = {code = int, error = "error message string", placement_id = "string"}
      if message.code == unityads.ERROR_NOT_INITIALIZED then
          -- Error related to SDK not initialized
      elseif message.code == unityads.ERROR_INTERNAL then
          -- Error related to environment or internal services
      elseif message.code == unityads.ERROR_INVALID_ARGUMENT then
          -- Error related to invalid arguments
      elseif message.code == unityads.ERROR_NO_FILL then
          -- Error related to there being no ads available
      elseif message.code == unityads.ERROR_TIMEOUT then
          -- Error related to there being no ads available
      end
  elseif message.event == unityads.EVENT_JSON_ERROR then
      -- message = {error = "error message string"}
  end
end
unityads.MSG_BANNER
local function defunityads_callback(self, message_id, message)
  if message.event == unityads.EVENT_LOADED then
      -- message = {placement_id = "string"}
      -- Banner is loaded and ready to be placed in the view hierarchy.
  elseif message.event == unityads.EVENT_LEFT_APPLICATION then
      -- message = {placement_id = "string"}
      -- Banner links outside the application.
  elseif message.event == unityads.EVENT_CLICKED then
      -- message = {placement_id = "string"}
      -- Banner is clicked.
  elseif message.event == unityads.EVENT_SDK_ERROR then
      -- message = {code = int, error = "error message string", placement_id = "string"}
      if message.code == unityads.ERROR_UNKNOWN then
          -- Unknown error 
      elseif message.code == unityads.ERROR_NATIVE then
          -- Error related to native
      elseif message.code == unityads.ERROR_WEBVIEW then
          -- Error related to webview
      elseif message.code == unityads.ERROR_NO_FILL then
          -- Error related to there being no ads available
      end
  elseif message.event == unityads.EVENT_JSON_ERROR then
      -- message = {error = "error message string"}
  end
end
unityads.MSG_IDFA
local function defunityads_callback(self, message_id, message)
  if message.event == unityads.EVENT_NOT_SUPPORTED then
      -- IDFA isn't supported
  elseif message.event == unityads.EVENT_STATUS_AUTORIZED then
  elseif message.event == unityads.EVENT_STATUS_DENIED then
  elseif message.event == unityads.EVENT_STATUS_NOT_DETERMINED then
  elseif message.event == unityads.EVENT_STATUS_RESTRICTED then
  elseif message.event == unityads.EVENT_JSON_ERROR then
      -- message = {error = "error message string"}
  end
end

If you have any issues, questions or suggestions please create an issue or contact me: [email protected]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].