multiple object mesh renderer off

could anyone help me out, how to make a small java script, that can loop trough all children of a gameobject, and disable the meshrenderer on it?
obvious the below script does not work, but how do i make it work?

thanx!

class MassMeshOff extends ScriptableWizard
{

    var theGameObject : GameObject;

    function OnWizardUpdate()
    {
        helpString = "Select Game Obects";
        isValid = (theGameObject != null);
    }

    function OnWizardCreate()
    {
        var gos = Selection.gameObjects;

        for (var go in gos) 
        {
            go.renderer.enabled = false;
        }
    }   

    @MenuItem("Custom/Mass Mesh Off", false, 4)
    static function massMeshOff()
    {
        ScriptableWizard.DisplayWizard("Mass Mesh Off", MassMeshOff, "Assign");
    }
}

2 Answers

2

http://unity3d.com/support/documentation/ScriptReference/Component.GetComponentsInChildren.html

see the example there: getting all HingeJoint’s and setting useSpring field false. you could do the same thing with the Renderer.

this method only gets the ‘active’ children as the description says. if you want to get inactive as well, make sure you call the method with ‘true’ parameter.

so far i had this (seems my edit on the first post dont want to show up, or its just me that does not see it)

class MassMeshOff extends
ScriptableWizard

{

//var theMaterial : Material;

var theGameObject : GameObject;



function OnWizardUpdate()

{

    helpString = "Select Game Obects";

    //isValid = (theMaterial != null);

    isValid = (theGameObject != null);

}



function OnWizardCreate()

{

// var gos =
Selection.gameObjects;

    for(var go in theGameObject)

    {

        //go.renderer.material = theMaterial;

        go.renderer.enabled = false;

    }

}    



@MenuItem("Custom/Mass Mesh Off", false, 4)

static function massMeshOff()

{

    ScriptableWizard.DisplayWizard("Mass

Mesh Off", MassMeshOff, “Assign”);

}

}