Getting the error m_InstanceID != 0 when calling Physics2D.IgnoreCollision()

Note that it is not “m_InstanceID == 0”, it’s “m_InstanceID != 0”. This is my method that’s producing the error:

public void RemoveFromLayer(int layer, Collider2D col = null) {
	if(col != null) {
		foreach(Collider2D refCol in colLayerArray[layer]) {
			if(refCol != null) {
				Physics2D.IgnoreCollision(refCol, col, true);
			}
		}
		colLayerArray[layer].Remove(col);
	}
}

colLayerArray is of type List< Collider2D >. It’s apart of a system I’ve made that allows for multiple layers (rendering and collision) in 2D. For example, multiple floors on a building in a top-down game.

If anyone could please explain how to fix the error, I would very much appreciate it.

I’ve had the m_InstanceID != 0 s bad for a while. Just today I tried…

       if ((c.gameObject.activeSelf) && (cc.gameObject.activeSelf))
        {
                   Physics2D.IgnoreCollision(c, cc, setignoreto);
         }

… and it cleared it up. Not sure if that’s helpful, but there’s not a lot of good info on the “m_InstanceID != 0” problem(s), hope this helps.

Might actually be caused by this: Unity Issue Tracker - [ExecuteInEditMode] Calling DestroyImmediate in OnEnable crashes Unity

Which would then indicate a need for an update to the very latest unity build, possibly the unity beta.

I have got similar issue for ‘m_InstanceID != InstanceID_None’
After some research and experiments, finally i found a way to resolve that:

Assets - > Reimport All

After the reimporting, unity will restarted, and then the issue gone.

I guess that is because Unity upgrading (I had upgraded to 5.5 yesterday). So try to reimport all after some weird error reports.