Hello Unityrs! 
I have this problem: I have a model in OBJ format with I load at runtime in my application.
now, I call AddComponent(MeshCollider) for enabling collision detection. It says that the meshcollider will read the mesh attached to the main object but when enquire the Inspector I can see that the Mesh field is empty…
why?
Kind Regards,
Giancarlo
You may need to explicitly assign the sharedMesh property:
var collider : MeshCollider = target.AddComponent(MeshCollider);
collider.sharedMesh = target.GetComponent(MeshFilter).sharedMesh;
Uhm… this is what I’ve done:
gObj.AddComponent(MeshCollider); in Javascript… where gObj is a GameObject and the mesh is built in the OBJ class where I call:
gs*.GetComponent().sharedMesh = m;*
where gs[ ] is an array of GameObjects and m is a Mesh type. Would it be the same?
Looks right I guess. Just double-check that you’re targetting the correct objects and using the correct mesh. Use some Debug.Log calls to validate your variables at run-time.
Using the inspector when running the application, it looks that the OBJ mesh has a MeshCollider and the sharedMesh points to the uploaded mesh…
the problem I have is that new model doesn’t interact with the plane allocated in the scene…
while a pre-allocated cube does.
Did you try simply use the ‘mesh’ not ‘sharedMesh’ ?
well I also tried to use BoxCollider but apparently any XXXCollider I attached has Extention = (0,0,0). I thought that once I created a collider and I assigned the gameObject, the collider gets dimensioned automatically… 
And anyway I just tried with ‘mesh’ and I get the warning that ‘mesh’ is obsolete and changed with ‘sharedMesh’.
So, the collider is there. Did you attach stuff like a RigidBody to it?
Yes I did,
but I have found out that if the ().convex = FALSE, well there is no collision
if it is TRUE, well there is collision but it behaves like a boxCollider 
Just for your reference, I use the this method to create mesh and add collider on the fly. (in unity2.6)
var g:GameObject = new GameObject.CreatePrimitive(PrimitiveType.Cube); // proxy object
//…
//…
var m:Mesh = json2mesh(h); // parse from JSON
g.GetComponent(MeshFilter).mesh = m;
g.GetComponent(MeshFilter).mesh.RecalculateBounds(); // Did you add this line after the mesh has been created ??
//…
//…
var c = g.GetComponent(BoxCollider);
GameObject.Destroy(c);
g.AddComponent(MeshCollider); // that’s all !
Hope that help.
Awww apple! thank you very much… I solved in using the MeshCollider and making it Convex, but definitely this is the solution I was looking for! 
Many thanks!