• 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 eclarke · Jan 05, 2016 at 09:11 AM · unity ads

Help displaying unity ads

I have a problem with displaying unity ads on a game I'm working on. The game automatically re-spawns the player whenever he dies, so I would like for an ad to be displayed, lets say, after every 5 re-spawns. Any help would be greatly appreciated.

Comment
Add comment
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

2 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by AlvinFassari · Jan 13, 2016 at 06:57 PM

Dont you need to sign the GameID to show ads?

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 Munchy2007 · Jan 13, 2016 at 08:25 PM 0
Share

Since Unity 5.2 (I think) the services tab takes care of things like the gameID.

But you shouldn't have made your post an answer, it should be converted to a comment.

avatar image
0

Answer by corn · Jan 05, 2016 at 12:45 PM

UnityAds is fairly easy to use. You should probably check UnityAds' knowledge base, the Manual page and the Scripting API page if you're confused about how to display an ad.

This kind of script should do the trick for what you're trying to achieve.

 int playerNumberOfRespawns = 0;
 
 void Respawn() 
 {
   // ... actual respawn code here

   // Displaying ads
   playerNumberOfRespawns++;

   if (playerNumberOfRespawns % 5 == 0 && Advertisement.IsReady()) 
   {
     Advertisement.Show();
   }
 }

Also keep in mind that no ad will show in the editor, this will only work on iOS or Android builds.

Comment
Add comment · Show 3 · 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 eclarke · Jan 06, 2016 at 06:47 PM 0
Share

Thank you very much, I will try to implement your script. I really didn't think on implementing it that way :D... Again, thank you :)

avatar image eclarke · Jan 08, 2016 at 03:26 PM 0
Share

This is the code I'm using... I'm running it in an update function... the ads are showing, but the game still continues to run in the background... not sure how to fix it ( kinda rusty program$$anonymous$$g :( )... any help? at least to guide me in the right direction?

 void Update () 
     {
         // If the player has died
         if (playerDead)
         {
             // Stop the camera movement
             cameraVelocity.speed = 0f;
 
             numberOfRespawns ++;
             
             if (numberOfRespawns % 5 == 0 && Advertisement.IsReady ()) {
                 showAd = true;
                 Advertisement.Show ();
             }
 
             if (!newGame && showAd == false)
             {
                 // We are now ready to start a new game
                 newGame = true;
                 // StartCoroutine needed to allow time 
                 // for the particle effects to finish
                 StartCoroutine(GameStart()); 
                 // Get the player score
                 playerScore = score.score;
                 // Pass the score to the method Highscore
                 Highscore(playerScore);
             } 
 
         }
 
     }
 
avatar image $$anonymous$$ eclarke · Jan 13, 2016 at 08:44 PM 0
Share

Well if it's about enemies, if I were you I'd make a static variable like pause and would set it to true when you are displaying the ads. Also I'd check if pause is false in your character AI and/or hero script and I'd only let these scripts to execute their code when pause is false. as for the other parts in the game, objects that don't move don't need to be checked.

Another approach would be setting Time.TimeScale to 0, while you're showing the ad, which makes the games' time stop and then you couldset it back to 1.0 when you finished showing the ad.

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

6 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Unity Ads: Non-fullscreen ads? 1 Answer

Services Menu under Services Tab Not loading 2 Answers

Unity Ads Service: How do i resize ads? 0 Answers

Getting error Gradle failed to fetch dependencies for Google admob plugin 4 Answers

Chartboost rewarded ad is crashing Unity Games? 0 Answers


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