- Home /
AdColony Integration
I use JavaScript and have coded my entire game in JS. I decided for ads I'm going to use AdColony, but all their scripts are in C# (which I don't know much of.) What I'm trying to do is call PlayAVideo when the mouse is clicked down (OnMouseDown.) Here is the script they gave me:
public class PlayAd : MonoBehaviour
{
public void Initialize()
{
// Assign any AdColony Delegates before calling Configure
AdColony.OnVideoFinished = this.OnVideoFinished;
// If you wish to use a the customID feature, you should call that now.
// Then, configure AdColony:
AdColony.Configure
(
"version:1.0,store:google", // Arbitrary app version and Android app store declaration.
"AppID", // ADC App ID from adcolony.com
"ZoneID", // A zone ID from adcolony.com
"ZoneID", // Any number of additional Zone IDS
"ZoneID"
);
}
// When a video is available, you may choose to play it in any fashion you like.
// Generally you will play them automatically during breaks in your game,
// or in response to a user action like clicking a button.
// Below is a method that could be called, or attached to a GUI action.
public void PlayAVideo( string zoneID )
{
// Check to see if a video is available in the zone.
if(AdColony.IsVideoAvailable(zoneID))
{
Debug.Log("Play AdColony Video");
// Call AdColony.ShowVideoAd with that zone to play an interstitial video.
// Note that you should also pause your game here (audio, etc.) AdColony will not
// pause your app for you.
AdColony.ShowVideoAd(zoneID);
}
else
{
Debug.Log("Video Not Available");
}
}
private void OnVideoFinished(bool ad_was_shown)
{
Debug.Log("On Video Finished");
// Resume your app here.
}
}
Thanks for any help
It helps if you tell us what's supposed to happen that isn't happening, I would guess it's that the video doesn't play. This could simply be because it's running in the editor?
I have exported to my android device, it still doesn't work. $$anonymous$$y problem is in the code. What I need to do is call PlayAVideo, this bit of the script:
public void PlayAVideo( string zoneID )
{
// Check to see if a video is available in the zone.
if(AdColony.IsVideoAvailable(zoneID))
{
Debug.Log("Play AdColony Video");
// Call AdColony.ShowVideoAd with that zone to play an interstitial video.
// Note that you should also pause your game here (audio, etc.) AdColony will not
// pause your app for you.
AdColony.ShowVideoAd(zoneID);
}
else
{
Debug.Log("Video Not Available");
}
}
I'm terms of translation to JavaScript, I assume the voids are kind of like functions? For example, I want to do something like this:
function PlayAVideo () {
//code to play the video here
}
function On$$anonymous$$ouseDown () {
PlayAVideo();
}
I could be wrong, but I hope this gives an idea of what I'm trying to do.
ok I haven't tried this but something like this for you js file might work
#pragma strict
function Start () {
AdColony.OnVideoFinished = OnVideoFinished;
AdColony.Configure
(
"version:1.0,store:google", // Arbitrary app version and Android app store declaration.
"AppID", // ADC App ID from adcolony.com
"ZoneID", // A zone ID from adcolony.com
"ZoneID", // Any number of additional Zone IDS
"ZoneID"
);
}
function PlayAVideo(zoneID : String)
{
// Check to see if a video is available in the zone.
if(AdColony.IsVideoAvailable(zoneID))
{
Debug.Log("Play AdColony Video");
// Call AdColony.ShowVideoAd with that zone to play an interstitial video.
// Note that you should also pause your game here (audio, etc.) AdColony will not
// pause your app for you.
AdColony.ShowVideoAd(zoneID);
}
else
{
Debug.Log("Video Not Available");
}
}
function OnVideoFinished () {
Debug.Log("On Video Finished");
}
Answer by joconnor · May 12, 2015 at 01:17 PM
AdColony only supports Android and iOS platforms (http://support.adcolony.com/customer/portal/articles/313635-sdk-platforms-os-support). Also make sure the app is set up in their dashboard, and that the Zone is set to Testing.
There is an official AdColony Unity plugin for iOS and Android that I'm using. I have my zone set to testing and everything set up properly, and I had it exported and running on my android device. Check the comment I posted for more info.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
what do you do after setting up admob in the unity editor 0 Answers
UnityEngine.Advertisements 0 Answers