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;*
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.