Search Unity

10-Step Integration Guide for Unity Ads in Unity

Discussion in 'Unity Ads & User Acquisition' started by unity-nikkolai, Jan 29, 2015.

  1. guyhazi

    guyhazi

    Joined:
    Mar 23, 2015
    Posts:
    56
    thanks for this awesome great super easy stuff never imagined it will be so easy.

    i used to work with libgdx and android ads were no problem but iOS ads were big headache because i was needed to use robovm binding witch were outdated and a mess so i moved to unity and its so easy.




    but i have an issue i don't know if its device dependant or not.
    i did exactly as said took the 2 scripts attached the to empty and inserted my game id and ads work but in the android app it take like 2 second to the ad to show up and meanwhile its a black screen so seeing it for the first time made me think my game crashed.
    i don't want my players to have that thought is it because i did something or i just the android device overloading? because the gameplay is very smooth no loading spikes.
    any one else experience that issue?
     
  2. chenklein2854

    chenklein2854

    Joined:
    Dec 30, 2014
    Posts:
    2
    Hi

    UnityAds/UnityAds.h' file not found

    I keep getting this error in Xcode (6.1) when trying to build for iOS

    please help

    thanks

    chen
     
  3. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    Sounds like the ad may not have been cached, it can take a few seconds to buffer before streaming. Sometimes it can take longer if the network conditions are poor. The attempt will eventually timeout after 20 seconds if the ad cannot be shown via streaming. In the near future, will have the option to disable streaming if you want to force caching only.
     
  4. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    I've seen a few users report this issue. Remove the Unity Ads assets from your project, then download and reimport the package from the Asset Store. Also, be sure to download Xcode 6.2 from the App Store.
     
  5. guyhazi

    guyhazi

    Joined:
    Mar 23, 2015
    Posts:
    56
    hi guys.

    i used this great 10 steps in my builds and when testing ads work perfectly on iOS and android now i need to upload them to the stores witch was easy made with android but apple ask me this :

    Does this app use the Advertising Identifier (IDFA)?
    The Advertising Identifier (IDFA) is a unique ID for each iOS device and is the only way to offer targeted ads. Users can choose to limit ad targeting on their iOS device.

    YesNo
    Ensure that you select the correct answer for Advertising Identifier (IDFA) usage. If your app does contain the IDFA and you select No, the binary will be permanently rejected and you will have to submit a different binary.

    should i click yes?
     
  6. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    Yes, Unity Ads uses the IDFA.

    Once you select "YES", there are three more questions Apple asks about the IDFA. You'll want to answer as follows:

    UnityAds-IDFA.png
     
  7. phailak

    phailak

    Joined:
    Feb 17, 2014
    Posts:
    13
    Anyway to check from another script (using Java) that the advertisement is still showing?
     
  8. devilsid

    devilsid

    Joined:
    Jan 12, 2015
    Posts:
    2
    Hello Sir,

    I have followed the steps and everything works fine. Now I just want to know how can I set my app which I added in the unity ads admin as test app to live after when I have published the app to the store. Also I will publishing the app to Amazon and I want to know if unity ads will work with the Amazon store. The game id in unity ads will be same right because I will not be able to change it after I have published my app.
     
  9. devilsid

    devilsid

    Joined:
    Jan 12, 2015
    Posts:
    2
    Hello
    Can anyone answer ?
     
  10. SuperFlyGames

    SuperFlyGames

    Joined:
    May 21, 2013
    Posts:
    3
    Hi, does anyone know where in the UnityAdsHelper script I can call a function that will happen if the Ads are not available to play due to no internet connection? At the moment I have the ShowAd function linked to a UI button, but if the device is not connected to the internet the player gets stuck in an infinite loop as the code I am currently using only progresses to the next scene after the Ad had successfully played. Any help would be GREATLY appreciated. Thanks.
     
  11. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,804
    use Advertisement.isReady() ?
     
  12. SuperFlyGames

    SuperFlyGames

    Joined:
    May 21, 2013
    Posts:
    3
    So just drop the code I want to use into this if statement?

    if (!Advertisement.isReady(zone))

    {

    Debug.LogWarning(string.Format("Unable to show ad. The ad placement zone ($0) is not ready.",
    zone == null ? "default" : zone));
    return false;

    }
     
  13. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,804
    I don't think you even need to pass the zone depending how you have all setup. They recently made a simple getting started blog post:

    http://blogs.unity3d.com/2015/04/09/integrating-unity-ads/
     
  14. Backward-pieS

    Backward-pieS

    Joined:
    Feb 7, 2013
    Posts:
    20
    Is it possible to initialize the ads in a different scene than the one they are called from? In other words, if I initialize them on the game's title screen will they be available in subsequently loaded scenes?
     
  15. YourDownfall

    YourDownfall

    Joined:
    Oct 26, 2014
    Posts:
    37
    I got a blackscreen with ten stars on it after an ad is played.
     
  16. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    Yes. Once you have initialized Unity Ads in your game, its instance persists between scene loads. The best place to initialize Unity Ads would be in a bootstrap scene, so that it provides Unity Ads with enough time to cache the first ad in the queue of available ads before you attempt to show.
     
  17. guyhazi

    guyhazi

    Joined:
    Mar 23, 2015
    Posts:
    56
    before i uploaded my app for review i build and ran it on my own iPhone device and the ads were working so i upload it to the app store and yesterday it finally got reviewed and i got binary rejection for not using ads so i mailed them the exact dummy instructions on how to get to the phase with the ads and after an hour or two it got approved and i was able to download and install.

    but guess what, now after watching a video ad, once the video is over or skip video is clicked, instead of getting to the "get that game you've just saw in the video screen", you have a white screen that does nothing and it kinda dead end because from that point you need to exit and reopen the game.

    any idea? ...how it got approved like that? how can i fix it?

    it was working fine when i tested it before archiving and uploading, and in android version its working perfect as well.

    i "checked" only the first box in nikkolai quote and not the second might that be the issue?
     
  18. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    The issue you're seeing with the end screen started occurring just a few days ago, and is something we're currently researching. We haven't identified the cause yet. Perhaps you can help us by answering the following questions:
    1. How often do you see the black screen when an ad is shown?
    2. Which ad campaigns are shown leading up to this issue occurring?
    3. Which country/region are you viewing ads from?
     
  19. guyhazi

    guyhazi

    Joined:
    Mar 23, 2015
    Posts:
    56
    1. its white screen and it happen after i watch a video to the end or click the skip button
    2. all the video i saw so far are having the same issue "cookie jam" game is one of them that i just saw so i could give an answer.
    3. im located at israel

    //////////////////////////////////

    I've just got another android device and installed the android version from the play store it have that black screen in the exact time like the iPhone white screen and both white iPhone screen and android black screen are reacting the same by "not reacting at all" and the video was "heroes charge", a few days ago when i last checked it was working properly
     
  20. zach22

    zach22

    Joined:
    Jan 22, 2014
    Posts:
    1
    Thanks for the scripts. They works well in unity, but 2 questions.

    1. what is the Zone Id used for?

    2. When I put it into Xcode it works but i get a black screen and if i stop Xcode and then launch it back on my game with out it on Xcode, it tries to open the game but then it crashes. any solution. is it just because its in the test mode?

    thanks for your help on unity ads
     
  21. Deleted User

    Deleted User

    Guest

    hi. im followed the steps but got some issues.

    first, after download and insert the Unity Ads Plugin and the two scripts, one of them get some errors on compile, is that normal?

    when I hit play, on my unity appears the test ad, but when I generate the apk and test on phone, nothings happen.
     
  22. KeepTrying

    KeepTrying

    Joined:
    Feb 23, 2011
    Posts:
    119
    When i build with UnityAds pack from UAS, the .APK is not even installing.
    Any tips ?
    Unity 5.0.1f1 / Android 5 / LG-D410hn
     

    Attached Files:

    Last edited: May 3, 2015
  23. nyxxstudios

    nyxxstudios

    Joined:
    May 4, 2015
    Posts:
    1
    Hello,

    i followed your instructions and it works perfectly in the unity editor. But when I tried to create an apk in order to test the project on my phone, i got this error:

    Error building Player: Win32Exception: ApplicationName='javac.exe', CommandLine='-bootclasspath "C:/Program Files (x86)/Android/android-sdk/platforms/android-15\android.jar" -d "C:\Jonas\Unity\Nützliche Beispielprojekte\WerbungUnityAds\Temp\StagingArea\bin\classes" -source 1.6 -target 1.6 -encoding UTF-8 "com\nyxxstudios\unityads\R.java" "com\unity3d\ads\android\R.java"', CurrentDirectory='C:\Jonas\Unity\Nützliche Beispielprojekte\WerbungUnityAds\Temp\StagingArea\gen'

    I really don't know the reason, any help or suggestions?
    Jonas
     
  24. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    Your JDK doesn't appear to be configured properly on your system yet. Looks like you're still missing an environment variable reference to the Java compiler within your Windows System Properties.

    Go to Control Panel > System > Advanced system Settings. From the Advanced tab of the System Properties window, select the Environment Variables button. Then add the following 3 user variables:
    1. ANDROID
    2. JDK
    3. PATH
    The value of the ANDROID variable should be the path to your Android SDK directory. The value of the JDK variable should be the path to the bin directory of the latest JDK version installed on your system.

    The value of PATH should then be: %JDK%;%ANDROID%

    Screenshot 2014-09-26 08.30.30.png
     
  25. Deleted User

    Deleted User

    Guest

    I think nobody see my post above... so im posting again, i need some help here.

    Im import UnityAds from Assets Store to my project normally, and when I try to build my code in monodevelop it shows 30 errors coming from scripts of unityads... and if I try to add the UnityEngine.Adversement on a script, dont exists this reference...

    theres a bug on the plugin? or I make something wrong?
     
  26. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,804
    You did not post any details before or now. What Unity version, what errors, etc?
     
    unity-nikkolai likes this.
  27. Deleted User

    Deleted User

    Guest

    Unity Version: 5.0.1f1
    UnityAds Plugin Version: 1.1.4

    im sending some images with details.

    im try to create a new blank project, and the adversement reference now appears, but the ads dont work
    in my ongoing project, i close the unity and reopen and the adversement now appears but have same error of the blank project.

    the error are on de Adversement.cs and VideoAds\UnityAds.cs

    moreerrors.png blankproject.png testeadscript.png adscripterror.png
     
  28. Deleted User

    Deleted User

    Guest

    despite the errors seem to be working , I'm using the class UnityAdsHelper, however the ads sometimes comes sometimes not.
     
  29. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    With test mode enabled, you'll be able to see 3 test ads per session. After the 3 there are no ads until you restart the game. This is so that you can test cases in which your user may have seen all available ads.

    With test mode disabled, it depends on the availability of ads by country as well as network conditions.

    Please keep in mind that the availability of ads is not guaranteed. This is why we provide methods to first check if ads are ready and can be shown. Users are limited to 25 ads per day per app (a rolling 24-hrs per ad view). They are also limited to seeing the same ad only once per hour.

    For most of Europe and North America, this typically isn't an issue. In countries where fill may be limited, the effects of this can be more obvious. For instance, if there are only 12 ad campaigns available in a user's country, they will only be able to see up to 12 ad campaigns per hour.

    In any case, if the user exhausts their daily limit of 25 ads, they won't see any more ads until the next day. During development, it's recommended that you enable test mode to ensure you will always have test ads available.
     
  30. simonini_thomas

    simonini_thomas

    Joined:
    Apr 30, 2015
    Posts:
    33
    Thank you for your tutorial.
    But I don't understand what is the difference between Timeout duration and Yield Time (I'm not English).

    I'm not sure but to be paid, the player must watch the ad a minimum of time ? What is this minimum ? Because it is not explained in UnityAds.

    Thanks
    Question.png
     
  31. Abhijit-Mukherjee

    Abhijit-Mukherjee

    Joined:
    Jan 9, 2015
    Posts:
    193
    Dose it work with web build ??? In Facebook Canvas how it will work ?????
     
  32. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    Sorry, it's not terribly clear from the variable name. I should comment the variable in code.

    Timeout Duration
    is the amount of time you should allow for Unity Ads to initialize and become ready from the time this script is run, typically when a scene containing the script is loaded. Keep in mind, Unity Ads can typically take around 15 seconds to initialize. Ads can take about 5 seconds to cache. If you're using this script in the first scene of your game, you should probably set the timeout to 20 or 30 seconds.

    Yield Time is the frequency in seconds that the script checks to see if Unity Ads is initialized and ready to show an ad. Setting the value to half a second (0.5) should be sufficient. Any more than 1 or 2 seconds can be excessive if the user is sitting on a static screen. This is more efficient than checking the status of Unity Ads with each frame.

    Please keep in mind that revenue is based on the quality of impressions. An impression is counted when an ad is started, but the potential for revenue is higher when the video is not skipped, counted as a completed view. However, there is still a chance to earn revenue on ads that a user skipped, even if it is less probable.

    A few things to consider:
    • Showing ads less often and with purpose can increase the quality of impressions, driving up the eCPM.
    • Showing ads without limit while allowing your users to skip videos can to drive down the eCPM, but also has the potential to maximize your earnings over time. After all, ads that aren't shown can't earn revenue.
    When you design your game, keep the quality of the user experience in mind when implementing ads. Try to implement ads with purpose. Does it make sense to show ads a certain points in your game? As a user, would you be willing to watch them? How can ads be used in your game to add to the experience rather than draw the user out of the game?

    Ads are a means for you as a developer to monetize your game, but the success of ads (and your game) can often hinge on how well you've integrated them into your gameplay.

    For more on design, be sure to check out Oscar Clark's, A Designer's Guide to Using Video Ads.
     
  33. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    At the moment, Unity Ads only supports iOS and Android. There is no support for web builds or Facebook Canvas.
     
  34. AnimisEngineering

    AnimisEngineering

    Joined:
    Jun 6, 2015
    Posts:
    11
    I'm struggling at the moment. I have published a paid app on the play store and want to add unity adds to a free version however whenever I add the package into my app it works in unity. When I build an apk file it gives me a app has stopped working and closes on my phone. Samsung Galaxy S5, no ad blocker that I'm aware of. Unity version is 4.6.1f. Any ideas. I tried to installed ArcWelder to test it on the PC but it fails in this also.
     
  35. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,804
    http://docs.unity3d.com/Manual/TroubleShootingAndroid.html

    without error details its the same as you would go to the car repair shop and say my car does not work, whats wrong?
     
    unity-nikkolai likes this.
  36. AnimisEngineering

    AnimisEngineering

    Joined:
    Jun 6, 2015
    Posts:
    11
    Ok I will have a look at the above information and take it from there, hopefully will get a resolution and will let you know or provide better details:)
     
  37. AnimisEngineering

    AnimisEngineering

    Joined:
    Jun 6, 2015
    Posts:
    11
    Ok after many hours of learning new things. I pulled the debug log and have the following. Fatal exception caused by java.lang.illegalArgumentException: gameid does not parse as an integer. I will look at code later this evening but any suggestions in meantime would be greatly appreciated.:)
     
  38. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,804
    Do you have your game id setup in the adshelper or in code hen you initialize?
     
  39. AnimisEngineering

    AnimisEngineering

    Joined:
    Jun 6, 2015
    Posts:
    11
    I didn't change the code but I added it in the inspector and it built ok and ran on unity. Only crashes when I build apk and pass over to the device. I don't have code in front of me just now so will step through it tonight after normal electrical day duties.
     
  40. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,804
    Ads run in special test mode in the editor so its not always reliable measurement.
     
    AnimisEngineering likes this.
  41. AnimisEngineering

    AnimisEngineering

    Joined:
    Jun 6, 2015
    Posts:
    11
    I'll let you know the details if I fix it. If you think of any other issues that it could be please let me know. I appreciate you taking the time to answer these posts.
     
  42. AnimisEngineering

    AnimisEngineering

    Joined:
    Jun 6, 2015
    Posts:
    11
    I'm still looking at this, can't see anything in the code but when I build in MonoDevelop I get 10 errors all of them are Default Parameters specifiers are not permitted cs0241. One thing I am struggling with is that I have been coding in JavaScript and not really got into c# yet so struggling to analyse these errors.
     
  43. AnimisEngineering

    AnimisEngineering

    Joined:
    Jun 6, 2015
    Posts:
    11
    I'm also getting a warning saying the referenced script on this Behaviour is missing? Could that be the problem?
     
  44. AnimisEngineering

    AnimisEngineering

    Joined:
    Jun 6, 2015
    Posts:
    11
    Ok I looked through everything again and it would seem that as I am still in test mode I had not entered the game id in to the test game id part in inspector. Hopefully that is all it was. Its like when you miss a ; off the end of a script line. At least the compilers these days point directly too the line where as it used to be you had to search for it. Thanks for your suggestions and hopefully that is me back on track again.
     
    Ostwind likes this.
  45. AnimisEngineering

    AnimisEngineering

    Joined:
    Jun 6, 2015
    Posts:
    11
    Nearly, there got my game up and running with test ads. I then unchecked the test mode in inspector and built the apk file with development mode still checked. All good game works well and a proper advert appears on my phone. The problem I have now is that I have unchecked the development build check box in build settings and made the apk file, when I try it on my phone it crashes the app just as the ads are about to appear. Any ideas, so close yet so far and my head hurts again from trying to figure this new hurdle out.
     
  46. AnimisEngineering

    AnimisEngineering

    Joined:
    Jun 6, 2015
    Posts:
    11
    I have the same fatal error, but I have checked the Game ID in the inspector, does it have to do with the code, is there something I need to change?

    I have caused by jave.lang.illegalArgumentException: gameID does not parse as an integer. Any ideas as I am hitting my head against a brick wall at the moment. Thanks it advance.
     
  47. Ostwind

    Ostwind

    Joined:
    Mar 22, 2011
    Posts:
    2,804
    Are you sure you have the latest version of UnityAds? maybe you have extra space where you entered the id?
     
  48. AnimisEngineering

    AnimisEngineering

    Joined:
    Jun 6, 2015
    Posts:
    11
    I was about to just give up today, hours and hours of looking and googling. Anyway watched the video on how to code the unity ads in and started with a blank project. All worked amazingly well. Took the basic ads script that was shown in the video and applied it into my game instead of the two files posted on this forum but it still failed. As a last ditch attempt I thought I would create an empty game object and just apply the simple script within the scene and I can't believe that was the problem. All is working. It would appear that because I had attached the scripts to a Gui object they didn't work. No idea why just really pleased that seems to be the problem sorted. Might be able to sleep properly now.
     
  49. unity-nikkolai

    unity-nikkolai

    Joined:
    Sep 18, 2014
    Posts:
    540
    Are you using Unity's new UI system? There is an example for how to use Unity Ads with Unity's UI system in the Unity Ads SpaceAds demo project. Take a look at the GetCoinsButton in the StartMenu scene within the demo project.
     
    Abhijit-Mukherjee likes this.
  50. Sylvir

    Sylvir

    Joined:
    Mar 21, 2015
    Posts:
    396
    not sure i am understanding how this works. I have it all set up and it opens saying the add would be here and things seem to be running fine. My question though is how do i set up under what situations i want the adds to appear? i dont want them to randomly just show up every few seconds as that would defiantly drive away any players from the fan base