控制unity对象下所有子物体的显示状态

Renderer[] rendererComponents = GetComponentsInChildren(true);
            Collider[] colliderComponents = GetComponentsInChildren(true);

            // Enable rendering:
            foreach (Renderer component in rendererComponents)
            {
                component.enabled = true;
            }

            // Enable colliders:
            foreach (Collider component in colliderComponents)
            {
                component.enabled = true;
            }

你可能感兴趣的:(Unity3D)