Mesh Collider doesn't work without reset

Hello, everyone!

I proceed my own mesh, and I want it interactable. But when I add a AddComponent(); in the code, it doesn’t work in the game.

If during the game I turn off and turn on the component again in the inspector panel, it works as needed.

Please, help me. I don’t understand, why it happens.

P.S. Blue circle is gaze and surface collide feedback from HoloToolkit for Mixed Reality.

P.P.S. I create GameObject, create surface and add mesh collider as GameObject.AddComponent();

EDITED

GameObject go= new GameObject(name);
 go.transform.SetParent(parent.transform);
 
 MeshFilter filter = go.AddComponent<MeshFilter>();
 Mesh mesh = filter.mesh;
         
 MeshRenderer mr = go.AddComponent<MeshRenderer>();

// something

 mesh.vertices = points.ToArray();
 mesh.triangles = triangles.ToArray();
 mesh.RecalculateNormals();
 
 go.AddComponent<MeshCollider>();

Do you also set the meshCollider’s mesh?
This is done in editor in Reset() (or when the component is added) but not when you do it in code. Just adding a meshCollider to a gameObject with a mesh renderer and filter won’t automatically assign the same mesh to the collider

I’ve solved it. I have 2 scripts. In the first, I called a function (second script) in which I created the mesh. And after that I changed my parent in the first.

Thus, you must firstly set the parent, and then create the mesh.

But why so, I did not understand (