How to turn off render shadows for all childs of an empty gameObject

I have a model with several empty gameObjects with several cubes in them, and I want to turn off casting shadows just for those cubs in those empty gameObjects without going in and manually disabling all of them(not during runtime).

Is there an easy shortcut I can do to accomplish this, or do I need to use a script/do it manually?

Thanks in advance!

the fast way, just create a simple script

public class JustModifyMeshRenderers : MonoBehaviour{

public bool castShadowsInChildren;

void OnValidate()
{
//and here get the children and modify it using the castShadowsInChildren value
//when you modify in the inspector the value of the boolean you will run this function

}

}

you can do it in 5 steps without coding :

  1. copy all empty game object that contain cubes into separate scene ( )
  2. in hierarchy tab in the search bar type t:meshrenderer (this will get you the list of game objects with mesh renderer component on them)
  3. select all game objects in the list (in the inspector tab you will get mesh renderer component display )
  4. in cast shadows field select off (clear the field in the search by clicking x), so the original hierarchy view returns
  5. select and paste those back in the origin scene

If your cubes have “cube” in their names you can isolate them in search by typing “t:meshrenderer cube”, and don’t need to copy them to another scene
here is the screenshot

link text

Perhaps - haven’t tested it - LINQ would be useful here?:

        var meshRendersInAvatar = avatar.GetComponentsInChildren<SkinnedMeshRenderer>();
        //meshRendersInAvatar.AsParallel().ForAll(m => m.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off);