Using the Unity Editor To Check "Convex" for Multiple Objects

So I’m trying to create a script to make my life a little easier without having to click every single object to add some physical properties. I have everything working except one thing.

I am trying to make all of my mesh colliders convex for my selected objects.

Here is what I have for code, which comes straight from the unity scripting reference, but it’s still not working:

@MenuItem (“GameObject/SetConvex”)
static function setConvex ()
{
Debug.Log (“Set object convex!!”);
for (var i = 0; i < Selection.gameObjects.length; i++)
{
Selection.gameObjects*.collider.convex = true;*

  • 	}*
    

}
This comes straight from unity’s scripting reference found here: [Script Reference][1]
[1]: http://unity3d.com/support/documentation/ScriptReference/MeshCollider-convex.html
But every time I run the script I get an error which says that " ‘convex’ is not a member of UnityEngine.Collider’. "
Anyone got any ideas?

It may be documented that way on the link provided, but documentation isn’t always right. I would take the compiler’s word for it more so than documentation. In any case, it doesn’t seem that the MeshCollider component is by default exposed to the user. I haven’t done this myself, but most likely what you’ll have to do is ( in c#):

for ( var i = 0; i < Selection.gameObjects.length; i++ )
{
     MeshCollider selectedCollider = Selection.gameObjects*.GetComponent<MeshCollider>();*

selectedCollider.convex = true;
}
If you’re using C# and are using MonoDevelop, Intellisense shows that collider does not inherit the member variable convex. Typically when you’re programming environment tells you that a variable or component isn’t exposed to you through Intellisense, it’s usually right and not the documentation.
I haven’t tested my code, but in theory it should do the trick.
EDIT: Also please use the insert code button, it would be very helpful in the future to read your code easier, no matter how short or long it may be.