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 :0)
UnityEngine.Events.UnityEvent.Invoke () (at :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.