Yes, this is no problem. Both MeshRenderer and SkinnedMeshRenderer both derive from Renderer. The Renderer class is where castShadows and receiveShadows are defined so you can just use something like:-
foreach (Object meshObject in MeshObjects)
{
Renderer renderer = meshObject as Renderer;
renderer.castShadows = false;
renderer.receiveShadows = false;
}
[ MenuItem("GameObject/Turn Off All Shadows") ]
static void TurnOffAllShadowsMenuItem ()
{
foreach (Renderer renderer in Object.FindObjectsOfType( typeof(Renderer)))
{
renderer.castShadows = false;
renderer.receiveShadows = false;
}
}
No need for explicit casts at all
EDIT:
Getting the .bounds in a single loop is possible if you have an array of their highest common class and use the ‘is’ keyword to determine the type of each object. However, it’s ill-adviced, as using separate loops is most likely more efficient and more readable.
Unfortunately not. You can do this in a language like Ruby and you can do it with your own classes in C# using interfaces, but you can’t do it with Unity API classes, I’m afraid.