• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Vakore · Jun 18, 2019 at 04:00 PM · lightingchild objectmeshrendererempty game object

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!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Freesmith · Jun 19, 2019 at 12:51 AM

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

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Vakore · Jun 20, 2019 at 12:56 PM 0
Share

Thanks! The solution worked great!

avatar image
1

Answer by unity_Y9AfbvAM22aTww · Jun 18, 2019 at 06:25 PM

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

}

}

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by harleydk · Jul 02, 2020 at 07:35 PM

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);
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

145 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

SpriteRenderer vs Meshrenderer lighting differences issue 0 Answers

Mesh darker than asset 1 Answer

Have an empty's position follow one of it's children's positions? 2 Answers

Spotlight not shining on certain objects 1 Answer

How to change one child object to another with the same armature? 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges