UnityEditor.GameObjectInspector.SetEnabledRecursive C# (CSharp) Method

SetEnabledRecursive() public static method

public static SetEnabledRecursive ( GameObject go, bool enabled ) : void
go UnityEngine.GameObject
enabled bool
return void
        public static void SetEnabledRecursive(GameObject go, bool enabled)
        {
            foreach (Renderer renderer in go.GetComponentsInChildren<Renderer>())
            {
                renderer.enabled = enabled;
            }
        }

Usage Example

Exemplo n.º 1
0
        private void DoRenderPreview()
        {
            GameObject gameObject = this.m_PreviewInstances[this.referenceTargetIndex];
            Bounds     bounds     = new Bounds(gameObject.transform.position, Vector3.zero);

            GameObjectInspector.GetRenderableBoundsRecurse(ref bounds, gameObject);
            float      num        = Mathf.Max(bounds.extents.magnitude, 0.0001f);
            float      num2       = num * 3.8f;
            Quaternion quaternion = Quaternion.Euler(-this.previewDir.y, -this.previewDir.x, 0f);
            Vector3    position   = bounds.center - quaternion * (Vector3.forward * num2);

            this.m_PreviewUtility.m_Camera.transform.position   = position;
            this.m_PreviewUtility.m_Camera.transform.rotation   = quaternion;
            this.m_PreviewUtility.m_Camera.nearClipPlane        = num2 - num * 1.1f;
            this.m_PreviewUtility.m_Camera.farClipPlane         = num2 + num * 1.1f;
            this.m_PreviewUtility.m_Light[0].intensity          = 0.7f;
            this.m_PreviewUtility.m_Light[0].transform.rotation = quaternion * Quaternion.Euler(40f, 40f, 0f);
            this.m_PreviewUtility.m_Light[1].intensity          = 0.7f;
            this.m_PreviewUtility.m_Light[1].transform.rotation = quaternion * Quaternion.Euler(340f, 218f, 177f);
            Color ambient = new Color(0.1f, 0.1f, 0.1f, 0f);

            InternalEditorUtility.SetCustomLighting(this.m_PreviewUtility.m_Light, ambient);
            bool fog = RenderSettings.fog;

            Unsupported.SetRenderSettingsUseFogNoDirty(false);
            GameObjectInspector.SetEnabledRecursive(gameObject, true);
            this.m_PreviewUtility.m_Camera.Render();
            GameObjectInspector.SetEnabledRecursive(gameObject, false);
            Unsupported.SetRenderSettingsUseFogNoDirty(fog);
            InternalEditorUtility.RemoveCustomLighting();
        }
All Usage Examples Of UnityEditor.GameObjectInspector::SetEnabledRecursive