Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by EnterX Studios · May 12, 2015 at 10:50 AM · c#ads

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

Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image xortrox · May 12, 2015 at 10:56 AM 0
Share

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?

avatar image EnterX Studios · May 12, 2015 at 01:16 PM 0
Share

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.

avatar image joconnor · May 12, 2015 at 02:26 PM 0
Share

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");
 }

1 Reply

· Add your reply
  • Sort: 
avatar image
0

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image EnterX Studios · May 12, 2015 at 01:24 PM 1
Share

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

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

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

Unity Admob not showing production ads [SOLVED] 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges