MatchThreeGame icon indicating copy to clipboard operation
MatchThreeGame copied to clipboard

Tries to destroy null game object

Open david-pfx opened this issue 5 years ago • 3 comments

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.GameObject.GetComponent[T] () (at C:/buildslave/unity/build/Runtime/Export/GameObject.bindings.cs:28) Utilities+<AnimatePotentialMatches>d__0.MoveNext () (at Assets/Scripts/Utilities.cs:22) UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at C:/buildslave/unity/build/Runtime/Export/Coroutines.cs:17) UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator) <CheckPotentialMatches>d__41:MoveNext() (at Assets/Scripts/ShapesManager.cs:530) UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

david-pfx avatar Apr 24 '19 14:04 david-pfx

Does the error happen on this line?

https://github.com/dgkanatsios/MatchThreeGame/blob/master/Assets/Scripts/Utilities.cs#L22

Have you found out the root cause? Thanks for the report!

dgkanatsios avatar Apr 24 '19 14:04 dgkanatsios

I would think you have game objects that are initialised in the wrong order (version sensitivity). I can tell you that when I play the game there are no visible animations. I can't tell you what the root cause is, but probably nothing very complicated for someone who knows their way around the code.

david-pfx avatar Apr 29 '19 05:04 david-pfx

After cloning the project, and updating to 2019.1 I'm also getting this error - adding

foreach (var item in potentialMatches)
{
    if(item == null) { continue; }
    ...
}

Is a working temporary fix - I encountered it after pressing the restart button in your demo scene.

BigHandInSky avatar Jun 03 '19 10:06 BigHandInSky