Skip to main content
added 31 characters in body
Source Link
wondra
  • 4.9k
  • 1
  • 22
  • 36

The error message is pretty descriptive:

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.

(emphasis mine)

Your selections list contains 'zombie' objects that were already destroyed in the C++ engine part and thus cannotit would be accessedsemantically incorrect to access them from the C# scripting engine part. Such 'zombie' GameObjects cannot be automatically 'deleted' in the C# part due to technical limitations and its up to you to handle them (drop the reference). Unity for convenience ensures that destroyed objects compare to null:

var selected = tempSelections[i];
if (selected == null) continue; //skip destroyed objects
if (GameObject//.Find(selected.name) == null).

The error message is pretty descriptive:

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.

(emphasis mine)

Your selections list contains 'zombie' objects that were already destroyed in the C++ engine part and thus cannot be accessed from the C# scripting engine part. Such 'zombie' GameObjects cannot be automatically 'deleted' in the C# part due to technical limitations and its up to you to handle them (drop the reference). Unity for convenience ensures that destroyed objects compare to null:

var selected = tempSelections[i];
if (selected == null) continue; //skip destroyed objects
if (GameObject.Find(selected.name) == null)

The error message is pretty descriptive:

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.

(emphasis mine)

Your selections list contains 'zombie' objects that were already destroyed in the C++ engine part and thus it would be semantically incorrect to access them from the C# scripting engine part. Such 'zombie' GameObjects cannot be automatically 'deleted' in the C# part due to technical limitations and its up to you to handle them (drop the reference). Unity for convenience ensures that destroyed objects compare to null:

var selected = tempSelections[i];
if (selected == null) continue; //skip destroyed objects
//...
Source Link
wondra
  • 4.9k
  • 1
  • 22
  • 36

The error message is pretty descriptive:

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.

(emphasis mine)

Your selections list contains 'zombie' objects that were already destroyed in the C++ engine part and thus cannot be accessed from the C# scripting engine part. Such 'zombie' GameObjects cannot be automatically 'deleted' in the C# part due to technical limitations and its up to you to handle them (drop the reference). Unity for convenience ensures that destroyed objects compare to null:

var selected = tempSelections[i];
if (selected == null) continue; //skip destroyed objects
if (GameObject.Find(selected.name) == null)