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");
}
}
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.