I have a menu that I created out of gameobjects. Here is the hierarchy:
Menu
->Video Ad
->Continue
Menu is the parent gameobject and Video Ad and Continue are children. On Video Ad I have a script that shows unityads and have UnityAdsVideoCompleted and UnityAdsHide delegates implemented. What I do is when UnityAdsHide delegate is called, I tried to hide Menu gameobject. Menu gameobject also has a script attached, and method that handles hiding with an animation. Everything works fine when the Application.LoadLevel is called for the first time. When I click on video ad, video ad is displayed, and when I click on close button on unityads, the delegate gets called, and then the Hide method in Menu gameobject. However, if the game is restarted by calling Application.LoadLevel() method, a strange thing happens. I see that Awake is called at the beginning, OnMouseDown is called on click and I have access to Menu gameobject. However, once the delegate is called, this pointer gets null, for that reason I cannot access Menu gameobject any more. Any help will be appreciated.
MissingReferenceException: The object of type ‘MenuController’ 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.Component.get_transform ()
MenuController.Hide (Boolean inside) (at Assets/Scripts/MenuController.cs:17)
VideoAds.ContinuePlay () (at Assets/Scripts/VideoAds.cs:112)
VideoAds.UnityAdsHide () (at Assets/Scripts/VideoAds.cs:94)
UnityEngine.Advertisements.UnityAds.onHide () (at Assets/Standard Assets/UnityAds/Scripts/Advertisements/VideoAds/UnityAds.cs:256)
UnityEngine.Advertisements.UnityAdsEditorPlaceholder.Hide () (at Assets/Standard Assets/UnityAds/Scripts/Advertisements/VideoAds/UnityAdsEditorPlaceholder.cs:79)
UnityEngine.Advertisements.UnityAdsEditorPlaceholder.windowFunc (Int32 id) (at Assets/Standard Assets/UnityAds/Scripts/Advertisements/VideoAds/UnityAdsEditorPlaceholder.cs:61)
UnityEngine.GUI.CallWindowDelegate (UnityEngine.WindowFunction func, Int32 id, UnityEngine.GUISkin _skin, Int32 forceRect, Single width, Single height, UnityEngine.GUIStyle style)