GetRenderableBoundsRecurse() public static method

public static GetRenderableBoundsRecurse ( Bounds &bounds, GameObject go ) : void
bounds UnityEngine.Bounds
go UnityEngine.GameObject
return void
        void SetupBounds(GameObject go)
        {
            m_IsValid = go != null && go != GetGenericAnimationFallback();

            if (go != null)
            {
                m_PreviewInstance = EditorUtility.InstantiateForAnimatorPreview(go);
                previewUtility.AddSingleGO(m_PreviewInstance);

                Bounds bounds = new Bounds(m_PreviewInstance.transform.position, Vector3.zero);
                GameObjectInspector.GetRenderableBoundsRecurse(ref bounds, m_PreviewInstance);

                m_BoundingVolumeScale = Mathf.Max(bounds.size.x, Mathf.Max(bounds.size.y, bounds.size.z));


                if (Animator && Animator.isHuman)
                {
                    m_AvatarScale = m_ZoomFactor = Animator.humanScale;
                }
                else
                {
                    m_AvatarScale = m_ZoomFactor = m_BoundingVolumeScale / 2;
                }
            }
        }
        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.camera.transform.position    = position;
            this.m_PreviewUtility.camera.transform.rotation    = quaternion;
            this.m_PreviewUtility.camera.nearClipPlane         = num2 - num * 1.1f;
            this.m_PreviewUtility.camera.farClipPlane          = num2 + num * 1.1f;
            this.m_PreviewUtility.lights[0].intensity          = 0.7f;
            this.m_PreviewUtility.lights[0].transform.rotation = quaternion * Quaternion.Euler(40f, 40f, 0f);
            this.m_PreviewUtility.lights[1].intensity          = 0.7f;
            this.m_PreviewUtility.lights[1].transform.rotation = quaternion * Quaternion.Euler(340f, 218f, 177f);
            this.m_PreviewUtility.ambientColor = new Color(0.1f, 0.1f, 0.1f, 0f);
            PrefabType prefabType = PrefabUtility.GetPrefabType(gameObject);
            bool       allowScriptableRenderPipeline = prefabType != PrefabType.DisconnectedModelPrefabInstance && prefabType != PrefabType.ModelPrefab;

            this.m_PreviewUtility.Render(allowScriptableRenderPipeline, true);
        }
        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();
        }
        public static void GetRenderableBoundsRecurse(ref Bounds bounds, GameObject go)
        {
            MeshRenderer meshRenderer = go.GetComponent(typeof(MeshRenderer)) as MeshRenderer;
            MeshFilter   meshFilter   = go.GetComponent(typeof(MeshFilter)) as MeshFilter;

            if (meshRenderer && meshFilter && meshFilter.sharedMesh)
            {
                if (bounds.extents == Vector3.zero)
                {
                    bounds = meshRenderer.bounds;
                }
                else
                {
                    bounds.Encapsulate(meshRenderer.bounds);
                }
            }
            SkinnedMeshRenderer skinnedMeshRenderer = go.GetComponent(typeof(SkinnedMeshRenderer)) as SkinnedMeshRenderer;

            if (skinnedMeshRenderer && skinnedMeshRenderer.sharedMesh)
            {
                if (bounds.extents == Vector3.zero)
                {
                    bounds = skinnedMeshRenderer.bounds;
                }
                else
                {
                    bounds.Encapsulate(skinnedMeshRenderer.bounds);
                }
            }
            SpriteRenderer spriteRenderer = go.GetComponent(typeof(SpriteRenderer)) as SpriteRenderer;

            if (spriteRenderer && spriteRenderer.sprite)
            {
                if (bounds.extents == Vector3.zero)
                {
                    bounds = spriteRenderer.bounds;
                }
                else
                {
                    bounds.Encapsulate(spriteRenderer.bounds);
                }
            }
            foreach (Transform transform in go.transform)
            {
                GameObjectInspector.GetRenderableBoundsRecurse(ref bounds, transform.gameObject);
            }
        }
        public static void GetRenderableBoundsRecurse(ref Bounds bounds, GameObject go)
        {
            MeshRenderer component1 = go.GetComponent(typeof(MeshRenderer)) as MeshRenderer;
            MeshFilter   component2 = go.GetComponent(typeof(MeshFilter)) as MeshFilter;

            if ((bool)((UnityEngine.Object)component1) && (bool)((UnityEngine.Object)component2) && (bool)((UnityEngine.Object)component2.sharedMesh))
            {
                if (bounds.extents == Vector3.zero)
                {
                    bounds = component1.bounds;
                }
                else
                {
                    bounds.Encapsulate(component1.bounds);
                }
            }
            SkinnedMeshRenderer component3 = go.GetComponent(typeof(SkinnedMeshRenderer)) as SkinnedMeshRenderer;

            if ((bool)((UnityEngine.Object)component3) && (bool)((UnityEngine.Object)component3.sharedMesh))
            {
                if (bounds.extents == Vector3.zero)
                {
                    bounds = component3.bounds;
                }
                else
                {
                    bounds.Encapsulate(component3.bounds);
                }
            }
            SpriteRenderer component4 = go.GetComponent(typeof(SpriteRenderer)) as SpriteRenderer;

            if ((bool)((UnityEngine.Object)component4) && (bool)((UnityEngine.Object)component4.sprite))
            {
                if (bounds.extents == Vector3.zero)
                {
                    bounds = component4.bounds;
                }
                else
                {
                    bounds.Encapsulate(component4.bounds);
                }
            }
            foreach (Transform transform in go.transform)
            {
                GameObjectInspector.GetRenderableBoundsRecurse(ref bounds, transform.gameObject);
            }
        }
 private void SetupBounds(GameObject go)
 {
     this.m_IsValid = (go != null) && (go != GetGenericAnimationFallback());
     if (go != null)
     {
         this.m_PreviewInstance = EditorUtility.InstantiateForAnimatorPreview(go);
         Bounds bounds = new Bounds(this.m_PreviewInstance.transform.position, Vector3.zero);
         GameObjectInspector.GetRenderableBoundsRecurse(ref bounds, this.m_PreviewInstance);
         this.m_BoundingVolumeScale = Mathf.Max(bounds.size.x, Mathf.Max(bounds.size.y, bounds.size.z));
         if ((this.Animator != null) && this.Animator.isHuman)
         {
             this.m_AvatarScale = this.m_ZoomFactor = this.Animator.humanScale;
         }
         else
         {
             this.m_AvatarScale = this.m_ZoomFactor = this.m_BoundingVolumeScale / 2f;
         }
     }
 }
        private void DoRenderPreview()
        {
            GameObjectInspector.PreviewData previewData = this.GetPreviewData();
            Bounds bounds = new Bounds(previewData.gameObject.transform.position, Vector3.zero);

            GameObjectInspector.GetRenderableBoundsRecurse(ref bounds, previewData.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);

            previewData.renderUtility.camera.transform.position    = position;
            previewData.renderUtility.camera.transform.rotation    = quaternion;
            previewData.renderUtility.camera.nearClipPlane         = num2 - num * 1.1f;
            previewData.renderUtility.camera.farClipPlane          = num2 + num * 1.1f;
            previewData.renderUtility.lights[0].intensity          = 0.7f;
            previewData.renderUtility.lights[0].transform.rotation = quaternion * Quaternion.Euler(40f, 40f, 0f);
            previewData.renderUtility.lights[1].intensity          = 0.7f;
            previewData.renderUtility.lights[1].transform.rotation = quaternion * Quaternion.Euler(340f, 218f, 177f);
            previewData.renderUtility.ambientColor = new Color(0.1f, 0.1f, 0.1f, 0f);
            previewData.renderUtility.Render(true, true);
        }
        public static void GetRenderableBoundsRecurse(ref Bounds bounds, GameObject go)
        {
            MeshRenderer meshRenderer = go.GetComponent(typeof(MeshRenderer)) as MeshRenderer;
            MeshFilter   meshFilter   = go.GetComponent(typeof(MeshFilter)) as MeshFilter;

            if (meshRenderer && meshFilter && meshFilter.sharedMesh)
            {
                if (bounds.extents == Vector3.zero)
                {
                    bounds = meshRenderer.bounds;
                }
                else
                {
                    bounds.Encapsulate(meshRenderer.bounds);
                }
            }
            SkinnedMeshRenderer skinnedMeshRenderer = go.GetComponent(typeof(SkinnedMeshRenderer)) as SkinnedMeshRenderer;

            if (skinnedMeshRenderer && skinnedMeshRenderer.sharedMesh)
            {
                if (bounds.extents == Vector3.zero)
                {
                    bounds = skinnedMeshRenderer.bounds;
                }
                else
                {
                    bounds.Encapsulate(skinnedMeshRenderer.bounds);
                }
            }
            SpriteRenderer spriteRenderer = go.GetComponent(typeof(SpriteRenderer)) as SpriteRenderer;

            if (spriteRenderer && spriteRenderer.sprite)
            {
                if (bounds.extents == Vector3.zero)
                {
                    bounds = spriteRenderer.bounds;
                }
                else
                {
                    bounds.Encapsulate(spriteRenderer.bounds);
                }
            }
            IEnumerator enumerator = go.transform.GetEnumerator();

            try
            {
                while (enumerator.MoveNext())
                {
                    Transform transform = (Transform)enumerator.Current;
                    GameObjectInspector.GetRenderableBoundsRecurse(ref bounds, transform.gameObject);
                }
            }
            finally
            {
                IDisposable disposable;
                if ((disposable = (enumerator as IDisposable)) != null)
                {
                    disposable.Dispose();
                }
            }
        }