"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. CustomControlScript.Update () (at Assets/Scripts/CustomControlScript.cs:51)."
This is the error I'm getting when this block of code:
Is executed ONLY AFTER this block of code in MySingleton is executed (If "S" is pressed before this function is executed, all is well):
How might I fix this issue? What I want to do is be able to clear my list whenever I want to and add new items to it afterward.
You should not empty the list with RemoveAt. Each times that function is called, the list size is decreased and i will still increase, which is going to be problematic with the loop and one element out of two won't be removed, hence the exception. Use Clear() instead.
answered May 09 '12 at 02:56 PM