Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Rewarded video Ads worked fine only once.

Discussion in 'Unity Ads & User Acquisition' started by georgeq, Mar 16, 2021.

Thread Status:
Not open for further replies.
  1. georgeq

    georgeq

    Joined:
    Mar 5, 2014
    Posts:
    662
    I'm implementing a rewarded video ad system. Everything worked fine when I ran the game the first time. When I ran the game for the second time (without touching anything), I got the following error:

    MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it.
    Your script should either check if it is null or you should not destroy the object.
    UnityEngine.Advertisements.Placeholder.HideSkipButton (UnityEngine.GameObject canvasGameObject) (at Library/PackageCache/com.unity.ads@3.5.2/Runtime/Advertisement/Platform/Editor/Placeholder.cs:179)
    UnityEngine.Advertisements.Placeholder.Show (System.String placementId, System.Boolean allowSkip) (at Library/PackageCache/com.unity.ads@3.5.2/Runtime/Advertisement/Platform/Editor/Placeholder.cs:80)
    UnityEngine.Advertisements.Platform.Editor.EditorPlatform.Show (System.String placementId) (at Library/PackageCache/com.unity.ads@3.5.2/Runtime/Advertisement/Platform/Editor/EditorPlatform.cs:173)
    UnityEngine.Advertisements.Platform.Platform.Show (System.String placementId, UnityEngine.Advertisements.ShowOptions showOptions) (at Library/PackageCache/com.unity.ads@3.5.2/Runtime/Advertisement/Platform/Platform.cs:104)
    UnityEngine.Advertisements.Advertisement.Show (System.String placementId) (at Library/PackageCache/com.unity.ads@3.5.2/Runtime/Advertisement/Advertisement.cs:142)
    ShowAd.PlaceAd () (at Assets/Project/Scripts/Runtime/UI/ShowAd.cs:50)
    UnityEngine.Events.InvokableCall.Invoke () (at <bad59441812943c7b8d5a5ba85795810>:0)
    UnityEngine.Events.UnityEvent.Invoke () (at <bad59441812943c7b8d5a5ba85795810>:0)
    UnityEngine.UI.Button.Press () (at C:/Program Files/Unity/Hub/Editor/2020.1.17f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/Button.cs:68)
    UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at C:/Program Files/Unity/Hub/Editor/2020.1.17f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/Button.cs:110)
    UnityEngine.EventSystems.ExecuteEvents.Execute (UnityEngine.EventSystems.IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/Program Files/Unity/Hub/Editor/2020.1.17f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:50)
    UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) (at C:/Program Files/Unity/Hub/Editor/2020.1.17f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/ExecuteEvents.cs:261)
    UnityEngine.EventSystems.EventSystem:Update() (at C:/Program Files/Unity/Hub/Editor/2020.1.17f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:376)

    After that nothing happes when I call Advertisement.Show nothing happens, no even an error message until I restart Unity. After restarting Unity I get the error above again.
     
    sivabalan12 likes this.
  2. zheyuanzhou

    zheyuanzhou

    Joined:
    Oct 29, 2017
    Posts:
    22
    It looks like 'MissingReferenceException' has the main reason you got errors in your projects
     
  3. georgeq

    georgeq

    Joined:
    Mar 5, 2014
    Posts:
    662
    This is obvious, and if the offending code was part of my project then I wouldn't be posting here. If you take the time to really read the error message it would also be obvious that the error message is generated by the Advertisements package itself:
    UnityEngine.Advertisements.Placeholder.HideSkipButton
     
  4. kyle-unity

    kyle-unity

    Unity Technologies

    Joined:
    Jan 6, 2020
    Posts:
    336
    Do you have any of the "Enter Play Mode" options checked in your project's Editor settings panel? It sounds like the ads placeholder code isn't being properly reset between play mode sessions. At any rate, this error won't affect your builds as they don't contain the placeholder code.
     

    Attached Files:

    sivabalan12 likes this.
  5. georgeq

    georgeq

    Joined:
    Mar 5, 2014
    Posts:
    662
    Yes, I had that option enabled. That was the problem. Thank you very much!
     
  6. Rayan30558

    Rayan30558

    Joined:
    Apr 22, 2018
    Posts:
    1
    same problem but I don't have "Enter play mode" options checked
     
    Vickey_Soni likes this.
Thread Status:
Not open for further replies.