how to make my 3D Gameobject invisible if no renderer attached ?

I have 3D object and I want to make it invisible by turning off its rendering. But when I run the code in runtime it shows ::
" Exception in callback: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. —> UnityEngine.MissingComponentException: There is no ‘Renderer’ attached to the “3dObject” game object, but a script is trying to access it."
I want to know if There is no renderer then how I am able to see that object in scene/game view. and also in inspector nothing is there (mesh renderer / renderer / mesh filter).
I’m Using c# : this.GetComponent().enabled=true;
I’m new in unity and I know its a pretty basic question but not getting anything. Need Help…

Are you sure that the GameObject doesn’t have a child, parent or sibling that has a Mesh or Skinned Mesh Renderer?

1 Like

GameObject.SetActive

sorry …in this model there is a long child list and one of them is having skinned mesh renderer.
Now my doubts are clear. but one thing, how to access all the renderers present on child of that particular 3D Model … I’m using :: Renderer[ ] ren = this.GetComponentsInChildren();

Every object has a tick that controls its Enabled state. But if you use the func above on the parent, then all children will become disabled automatically. The children in the inspector will show they are active but that’s only local state. Meaning you might disable an object there and when you reenable the parent , that object will remain inactive. But since the parent is disabled then the global state of all children will be disabled.