void UpdatePivot(GameObject obj)
{
Mesh mesh = obj.GetComponent<MeshFilter>().mesh;
Vector3[] verts= mesh.vertices;
Vector3 p = new Vector3(verts[0].x+verts[1].x+verts[2].x)/3f, verts[0].y+verts[1].y+verts[2].y)/3f, verts[0].z+verts[1].z+verts[2].z)/3f);
obj.transform.position = p;
for (int i = 0; i < verts.Length; i++)
{
verts[i] -= p;
}
mesh.vertices = verts;
mesh.RecalculateBounds();
}