Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Where are the examples?

Discussion in 'Unity Ads & User Acquisition' started by 00christian00, Nov 24, 2021.

  1. 00christian00

    00christian00

    Joined:
    Jul 22, 2012
    Posts:
    1,035
    So I updated the sdk to 3.7.5 and saw the workflow changed completely again....
    Why there are is no complete example of the sdk?
    The documentation just provide scattered pieces of code that don't provide a complete picture of how to use it, forcing us to go by trial and error.

    One example:
    Code (CSharp):
    1. public void LoadAd()
    2.     {
    3.         // IMPORTANT! Only load content AFTER initialization (in this example, initialization is handled in a different script).
    4.         Debug.Log("Loading Ad: " + _adUnitId);
    5.         Advertisement.Load(_adUnitId, this);
    6.     }
    Uuum, yeah, except that the initialization example just works on its own, sort of fire and forget, and there is no cohesion with the show ads example. I am sure there are many things that needs to be covered and I think the minimum is to provide a template on how to use the new sdk just like unity purchasing sdk do.
    Another example, the LoadAd method above is defined but never used in the example snippet. At which point is best to call it?
    Do I call it right after the initialization in a sort of preload?

    Another example:
    Code (CSharp):
    1.  public void OnUnityAdsFailedToLoad(string adUnitId, UnityAdsLoadError error, string message)
    2.     {
    3.         Debug.Log($"Error loading Ad Unit: {adUnitId} - {error.ToString()} - {message}");
    4.         // Optionally execite code if the Ad Unit fails to load, such as attempting to try again.
    5.     }
    So I just call the LoadAd again? Aren't we offloading too much to the developer? This sort of things should be handled automatically by the sdk.
     
  2. Unity_Jae

    Unity_Jae

    Unity Technologies

    Joined:
    Aug 30, 2021
    Posts:
    50
    Hello 00christian00,

    Thanks for sharing your concerns, and sorry to hear that you are having trouble with Unity Ads SDK.

    First, I indeed agree with your concern. Examples of SDK are somehow missing. I talked with our SDK team directly about your problems and want to share the information received from the SDK team.

    Second, not sure the workflow actually did change with 3.7.5. May I ask what version of SDK you were using before?

    Outside of that, you can call `LoadAd()` after the initialization. Can bind with a button event, or can call in `OnInitializationComplete()` method. And you could also try to call `LoadAd()` in `OnUnityAdsFailedToLoad()` when it fails.

    I hope this answer makes sense. Thank you for sharing your concerns and problems.
    Please let me know if there's anything else I can do or provide more information for you. Have a nice day.
     
  3. 00christian00

    00christian00

    Joined:
    Jul 22, 2012
    Posts:
    1,035
    Hi, thanks for your reply.
    I wrote an abstraction layer above the previous sdk long ago and only recently I started using it in my game and decided to upgrade to the latest sdk. I think it was last updated(talking of my code) around 3.5 or 3.6.
    It was working fine but it was complaining that some method were obsolete like the result callback on the show ad, so I decided to adopt the new way with the interfaces, but it seem overly complex.
    I found a compromise not documented in the integration example, and that is to initialize with the enablePerPlacementLoad set to false, this lets me keep most of the workflow same as before.
     
  4. Unity_Jae

    Unity_Jae

    Unity Technologies

    Joined:
    Aug 30, 2021
    Posts:
    50
    Hello, 00christian00

    Glad to hear that you found a solution to your problem. Also, sorry that our documentation, samples are outdated or lacking.
    Currently, we are planning to update our SDK's version to 4.0. Hence, to avoid conflicts when updating the version, here is the document link about API deprecation. https://unityads.unity3d.com/help/resources/api-deprecation
    Additionally, our SDK team understands the importance of documenting and providing samples to improve user experience. Thank you for providing a valuable opinion, we will update documents and provide better samples in the future.
     
    00christian00 likes this.
  5. 00christian00

    00christian00

    Joined:
    Jul 22, 2012
    Posts:
    1,035
    Thanks. Judging the link you have given me, even my compromise is already obsolete and will be removed in 4.0 :(