public static Vector3 GetRenderableCenterRecurse(GameObject go, int minDepth, int maxDepth)
        {
            Vector3 zero = Vector3.zero;
            float   renderableCenterRecurse = GameObjectInspector.GetRenderableCenterRecurse(ref zero, go, 0, minDepth, maxDepth);

            return((double)renderableCenterRecurse <= 0.0 ? go.transform.position : zero / renderableCenterRecurse);
        }
        private void DoStaticToggleField(GameObject go)
        {
            Rect rect = GUILayoutUtility.GetRect(GameObjectInspector.s_Styles.staticContent, EditorStyles.toggle, new GUILayoutOption[]
            {
                GUILayout.ExpandWidth(false)
            });

            EditorGUI.BeginProperty(rect, GUIContent.none, this.m_StaticEditorFlags);
            EditorGUI.BeginChangeCheck();
            Rect position = rect;

            EditorGUI.showMixedValue |= GameObjectInspector.ShowMixedStaticEditorFlags((StaticEditorFlags)this.m_StaticEditorFlags.intValue);
            Event     current = Event.current;
            EventType type    = current.type;
            bool      flag    = current.type == EventType.MouseDown && current.button != 0;

            if (flag)
            {
                current.type = EventType.Ignore;
            }
            bool flagValue = EditorGUI.ToggleLeft(position, GameObjectInspector.s_Styles.staticContent, go.isStatic);

            if (flag)
            {
                current.type = type;
            }
            EditorGUI.showMixedValue = false;
            if (EditorGUI.EndChangeCheck())
            {
                SceneModeUtility.SetStaticFlags(base.targets, -1, flagValue);
                base.serializedObject.SetIsDifferentCacheDirty();
                GUIUtility.ExitGUI();
            }
            EditorGUI.EndProperty();
        }
        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 bool HasRenderablePartsRecurse(GameObject go)
        {
            MeshRenderer exists     = go.GetComponent(typeof(MeshRenderer)) as MeshRenderer;
            MeshFilter   meshFilter = go.GetComponent(typeof(MeshFilter)) as MeshFilter;

            if (exists && meshFilter && meshFilter.sharedMesh)
            {
                return(true);
            }
            SkinnedMeshRenderer skinnedMeshRenderer = go.GetComponent(typeof(SkinnedMeshRenderer)) as SkinnedMeshRenderer;

            if (skinnedMeshRenderer && skinnedMeshRenderer.sharedMesh)
            {
                return(true);
            }
            SpriteRenderer spriteRenderer = go.GetComponent(typeof(SpriteRenderer)) as SpriteRenderer;

            if (spriteRenderer && spriteRenderer.sprite)
            {
                return(true);
            }
            foreach (Transform transform in go.transform)
            {
                if (GameObjectInspector.HasRenderablePartsRecurse(transform.gameObject))
                {
                    return(true);
                }
            }
            return(false);
        }
        public static bool HasRenderablePartsRecurse(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))
            {
                return(true);
            }
            SkinnedMeshRenderer component3 = go.GetComponent(typeof(SkinnedMeshRenderer)) as SkinnedMeshRenderer;

            if ((bool)((UnityEngine.Object)component3) && (bool)((UnityEngine.Object)component3.sharedMesh))
            {
                return(true);
            }
            SpriteRenderer component4 = go.GetComponent(typeof(SpriteRenderer)) as SpriteRenderer;

            if ((bool)((UnityEngine.Object)component4) && (bool)((UnityEngine.Object)component4.sprite))
            {
                return(true);
            }
            foreach (Component component5 in go.transform)
            {
                if (GameObjectInspector.HasRenderablePartsRecurse(component5.gameObject))
                {
                    return(true);
                }
            }
            return(false);
        }
        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);
        }
Beispiel #8
0
        void SetupBounds(GameObject go)
        {
            m_IsValid = go != null && go != GetGenericAnimationFallback();

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

                m_Previewables = m_PreviewInstance.GetComponentsInChildren <IAnimationPreviewable>();
                var bounds = GameObjectInspector.GetRenderableBounds(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;
                }
            }
        }
Beispiel #9
0
 public static bool IsValidPreviewGameObject(GameObject target, ModelImporterAnimationType requiredClipType)
 {
     if (target != null && !target.activeSelf)
     {
         Debug.LogWarning("Can't preview inactive object, using fallback object");
     }
     return(target != null && target.activeSelf && GameObjectInspector.HasRenderableParts(target) && (requiredClipType == ModelImporterAnimationType.None || AvatarPreview.GetAnimationType(target) == requiredClipType));
 }
        private static float GetRenderableCenterRecurse(ref Vector3 center, GameObject go, int depth, int minDepth, int maxDepth)
        {
            if (depth > maxDepth)
            {
                return(0f);
            }
            float num = 0f;

            if (depth > minDepth)
            {
                MeshRenderer        meshRenderer        = go.GetComponent(typeof(MeshRenderer)) as MeshRenderer;
                MeshFilter          x                   = go.GetComponent(typeof(MeshFilter)) as MeshFilter;
                SkinnedMeshRenderer skinnedMeshRenderer = go.GetComponent(typeof(SkinnedMeshRenderer)) as SkinnedMeshRenderer;
                SpriteRenderer      spriteRenderer      = go.GetComponent(typeof(SpriteRenderer)) as SpriteRenderer;
                if (meshRenderer == null && x == null && skinnedMeshRenderer == null && spriteRenderer == null)
                {
                    num     = 1f;
                    center += go.transform.position;
                }
                else
                {
                    if (meshRenderer != null && x != null)
                    {
                        if (Vector3.Distance(meshRenderer.bounds.center, go.transform.position) < 0.01f)
                        {
                            num     = 1f;
                            center += go.transform.position;
                        }
                    }
                    else
                    {
                        if (skinnedMeshRenderer != null)
                        {
                            if (Vector3.Distance(skinnedMeshRenderer.bounds.center, go.transform.position) < 0.01f)
                            {
                                num     = 1f;
                                center += go.transform.position;
                            }
                        }
                        else
                        {
                            if (spriteRenderer != null && Vector3.Distance(spriteRenderer.bounds.center, go.transform.position) < 0.01f)
                            {
                                num     = 1f;
                                center += go.transform.position;
                            }
                        }
                    }
                }
            }
            depth++;
            foreach (Transform transform in go.transform)
            {
                num += GameObjectInspector.GetRenderableCenterRecurse(ref center, transform.gameObject, depth, minDepth, maxDepth);
            }
            return(num);
        }
 private void SetPreviewCharacterEnabled(bool enabled, bool showReference)
 {
     if (this.m_PreviewInstance != null)
     {
         GameObjectInspector.SetEnabledRecursive(this.m_PreviewInstance, enabled);
     }
     GameObjectInspector.SetEnabledRecursive(this.m_ReferenceInstance, showReference && enabled);
     GameObjectInspector.SetEnabledRecursive(this.m_DirectionInstance, showReference && enabled);
     GameObjectInspector.SetEnabledRecursive(this.m_PivotInstance, showReference && enabled);
     GameObjectInspector.SetEnabledRecursive(this.m_RootInstance, showReference && enabled);
 }
Beispiel #12
0
 public static bool IsValidPreviewGameObject(GameObject target, ModelImporterAnimationType requiredClipType)
 {
     if ((Object)target != (Object)null && !target.activeSelf)
     {
         Debug.LogWarning((object)"Can't preview inactive object, using fallback object");
     }
     if ((Object)target != (Object)null && target.activeSelf && GameObjectInspector.HasRenderablePartsRecurse(target))
     {
         return((requiredClipType == ModelImporterAnimationType.None ? 0 : (AvatarPreview.GetAnimationType(target) != requiredClipType ? 1 : 0)) == 0);
     }
     return(false);
 }
 private void CreatePreviewInstances()
 {
     this.DestroyPreviewInstances();
     if (this.m_PreviewInstances == null)
     {
         this.m_PreviewInstances = new List <GameObject>(this.targets.Length);
     }
     for (int index = 0; index < this.targets.Length; ++index)
     {
         GameObject go = EditorUtility.InstantiateForAnimatorPreview(this.targets[index]);
         GameObjectInspector.SetEnabledRecursive(go, false);
         this.m_PreviewInstances.Add(go);
     }
 }
 private void CreatePreviewInstances()
 {
     this.DestroyPreviewInstances();
     if (this.m_PreviewInstances == null)
     {
         this.m_PreviewInstances = new List <GameObject>(base.targets.Length);
     }
     for (int i = 0; i < base.targets.Length; i++)
     {
         GameObject gameObject = EditorUtility.InstantiateForAnimatorPreview(base.targets[i]);
         GameObjectInspector.SetEnabledRecursive(gameObject, false);
         this.m_PreviewInstances.Add(gameObject);
     }
 }
        public static Vector3 GetRenderableCenterRecurse(GameObject go, int minDepth, int maxDepth)
        {
            Vector3 vector = Vector3.zero;
            float   renderableCenterRecurse = GameObjectInspector.GetRenderableCenterRecurse(ref vector, go, 0, minDepth, maxDepth);

            if (renderableCenterRecurse > 0f)
            {
                vector /= renderableCenterRecurse;
            }
            else
            {
                vector = go.transform.position;
            }
            return(vector);
        }
        private bool HasStaticPreview()
        {
            if (base.targets.Length > 1)
            {
                return(true);
            }
            if (this.target == null)
            {
                return(false);
            }
            GameObject gameObject = this.target as GameObject;
            Camera     exists     = gameObject.GetComponent(typeof(Camera)) as Camera;

            return(exists || GameObjectInspector.HasRenderablePartsRecurse(gameObject));
        }
        private static float GetRenderableCenterRecurse(ref Vector3 center, GameObject go, int depth, int minDepth, int maxDepth)
        {
            if (depth > maxDepth)
            {
                return(0.0f);
            }
            float num = 0.0f;

            if (depth > minDepth)
            {
                MeshRenderer        component1 = go.GetComponent(typeof(MeshRenderer)) as MeshRenderer;
                MeshFilter          component2 = go.GetComponent(typeof(MeshFilter)) as MeshFilter;
                SkinnedMeshRenderer component3 = go.GetComponent(typeof(SkinnedMeshRenderer)) as SkinnedMeshRenderer;
                SpriteRenderer      component4 = go.GetComponent(typeof(SpriteRenderer)) as SpriteRenderer;
                if ((UnityEngine.Object)component1 == (UnityEngine.Object)null && (UnityEngine.Object)component2 == (UnityEngine.Object)null && ((UnityEngine.Object)component3 == (UnityEngine.Object)null && (UnityEngine.Object)component4 == (UnityEngine.Object)null))
                {
                    num    = 1f;
                    center = center + go.transform.position;
                }
                else if ((UnityEngine.Object)component1 != (UnityEngine.Object)null && (UnityEngine.Object)component2 != (UnityEngine.Object)null)
                {
                    if ((double)Vector3.Distance(component1.bounds.center, go.transform.position) < 0.00999999977648258)
                    {
                        num    = 1f;
                        center = center + go.transform.position;
                    }
                }
                else if ((UnityEngine.Object)component3 != (UnityEngine.Object)null)
                {
                    if ((double)Vector3.Distance(component3.bounds.center, go.transform.position) < 0.00999999977648258)
                    {
                        num    = 1f;
                        center = center + go.transform.position;
                    }
                }
                else if ((UnityEngine.Object)component4 != (UnityEngine.Object)null && (double)Vector3.Distance(component4.bounds.center, go.transform.position) < 0.00999999977648258)
                {
                    num    = 1f;
                    center = center + go.transform.position;
                }
            }
            ++depth;
            foreach (Transform transform in go.transform)
            {
                num += GameObjectInspector.GetRenderableCenterRecurse(ref center, transform.gameObject, depth, minDepth, maxDepth);
            }
            return(num);
        }
        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 bool HasStaticPreview()
        {
            if (this.targets.Length > 1)
            {
                return(true);
            }
            if (this.target == (UnityEngine.Object)null)
            {
                return(false);
            }
            GameObject target = this.target as GameObject;

            if ((bool)((UnityEngine.Object)(target.GetComponent(typeof(Camera)) as Camera)))
            {
                return(true);
            }
            return(GameObjectInspector.HasRenderablePartsRecurse(target));
        }
 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 bool HasStaticPreview()
        {
            bool result;

            if (base.targets.Length > 1)
            {
                result = true;
            }
            else if (base.target == null)
            {
                result = false;
            }
            else
            {
                GameObject gameObject = base.target as GameObject;
                Camera     exists     = gameObject.GetComponent(typeof(Camera)) as Camera;
                result = (exists || GameObjectInspector.HasRenderableParts(gameObject));
            }
            return(result);
        }
        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);
        }
        internal bool DrawInspector(Rect contentRect)
        {
            if (GameObjectInspector.s_styles == null)
            {
                GameObjectInspector.s_styles = new GameObjectInspector.Styles();
            }
            this.serializedObject.Update();
            GameObject target1 = this.target as GameObject;

            EditorGUIUtility.labelWidth = 52f;
            bool enabled1 = GUI.enabled;

            GUI.enabled = true;
            GUI.Label(new Rect(contentRect.x, contentRect.y, contentRect.width, contentRect.height + 3f), GUIContent.none, EditorStyles.inspectorBig);
            GUI.enabled = enabled1;
            float      width1     = contentRect.width;
            float      y          = contentRect.y;
            GUIContent guiContent = (GUIContent)null;
            PrefabType prefabType = PrefabType.None;

            if (this.m_AllOfSamePrefabType)
            {
                prefabType = PrefabUtility.GetPrefabType((UnityEngine.Object)target1);
                switch (prefabType)
                {
                case PrefabType.None:
                    guiContent = GameObjectInspector.s_styles.goIcon;
                    break;

                case PrefabType.Prefab:
                case PrefabType.PrefabInstance:
                case PrefabType.DisconnectedPrefabInstance:
                    guiContent = GameObjectInspector.s_styles.prefabIcon;
                    break;

                case PrefabType.ModelPrefab:
                case PrefabType.ModelPrefabInstance:
                case PrefabType.DisconnectedModelPrefabInstance:
                    guiContent = GameObjectInspector.s_styles.modelIcon;
                    break;

                case PrefabType.MissingPrefabInstance:
                    guiContent = GameObjectInspector.s_styles.prefabIcon;
                    break;
                }
            }
            else
            {
                guiContent = GameObjectInspector.s_styles.typelessIcon;
            }
            EditorGUI.ObjectIconDropDown(new Rect(3f, 4f + y, 24f, 24f), this.targets, true, guiContent.image as Texture2D, this.m_Icon);
            EditorGUI.BeginDisabledGroup(prefabType == PrefabType.ModelPrefab);
            EditorGUI.PropertyField(new Rect(34f, 4f + y, 14f, 14f), this.m_IsActive, GUIContent.none);
            float num1   = GameObjectInspector.s_styles.staticFieldToggleWidth + 15f;
            float width2 = (float)((double)width1 - 52.0 - (double)num1 - 5.0);

            EditorGUI.DelayedTextField(new Rect(52f, (float)(4.0 + (double)y + 1.0), width2, 16f), this.m_Name, GUIContent.none);
            Rect totalPosition = new Rect(width1 - num1, 4f + y, GameObjectInspector.s_styles.staticFieldToggleWidth, 16f);

            EditorGUI.BeginProperty(totalPosition, GUIContent.none, this.m_StaticEditorFlags);
            EditorGUI.BeginChangeCheck();
            Rect position1 = totalPosition;

            EditorGUI.showMixedValue |= GameObjectInspector.ShowMixedStaticEditorFlags((StaticEditorFlags)this.m_StaticEditorFlags.intValue);
            Event     current = Event.current;
            EventType type    = current.type;
            bool      flag    = current.type == EventType.MouseDown && current.button != 0;

            if (flag)
            {
                current.type = EventType.Ignore;
            }
            bool flagValue = EditorGUI.ToggleLeft(position1, "Static", target1.isStatic);

            if (flag)
            {
                current.type = type;
            }
            EditorGUI.showMixedValue = false;
            if (EditorGUI.EndChangeCheck())
            {
                SceneModeUtility.SetStaticFlags(this.targets, -1, flagValue);
                this.serializedObject.SetIsDifferentCacheDirty();
            }
            EditorGUI.EndProperty();
            EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = this.m_StaticEditorFlags.hasMultipleDifferentValues;
            int  changedFlags;
            bool changedToValue;

            EditorGUI.EnumMaskField(new Rect(totalPosition.x + GameObjectInspector.s_styles.staticFieldToggleWidth, totalPosition.y, 10f, 14f), (Enum)GameObjectUtility.GetStaticEditorFlags(target1), GameObjectInspector.s_styles.staticDropdown, out changedFlags, out changedToValue);
            EditorGUI.showMixedValue = false;
            if (EditorGUI.EndChangeCheck())
            {
                SceneModeUtility.SetStaticFlags(this.targets, changedFlags, changedToValue);
                this.serializedObject.SetIsDifferentCacheDirty();
            }
            float num2 = 4f;
            float num3 = 4f;

            EditorGUIUtility.fieldWidth = (float)(((double)width1 - (double)num2 - 52.0 - (double)GameObjectInspector.s_styles.layerFieldWidth - (double)num3) / 2.0);
            string tag;

            try
            {
                tag = target1.tag;
            }
            catch (Exception ex)
            {
                tag = "Undefined";
            }
            EditorGUIUtility.labelWidth = GameObjectInspector.s_styles.tagFieldWidth;
            Rect rect = new Rect(52f - EditorGUIUtility.labelWidth, 24f + y, EditorGUIUtility.labelWidth + EditorGUIUtility.fieldWidth, 16f);

            EditorGUI.BeginProperty(rect, GUIContent.none, this.m_Tag);
            EditorGUI.BeginChangeCheck();
            string str = EditorGUI.TagField(rect, EditorGUIUtility.TempContent("Tag"), tag);

            if (EditorGUI.EndChangeCheck())
            {
                this.m_Tag.stringValue = str;
                Undo.RecordObjects(this.targets, "Change Tag of " + this.targetTitle);
                foreach (UnityEngine.Object target2 in this.targets)
                {
                    (target2 as GameObject).tag = str;
                }
            }
            EditorGUI.EndProperty();
            EditorGUIUtility.labelWidth = GameObjectInspector.s_styles.layerFieldWidth;
            rect = new Rect(52f + EditorGUIUtility.fieldWidth + num2, 24f + y, EditorGUIUtility.labelWidth + EditorGUIUtility.fieldWidth, 16f);
            EditorGUI.BeginProperty(rect, GUIContent.none, this.m_Layer);
            EditorGUI.BeginChangeCheck();
            int layer = EditorGUI.LayerField(rect, EditorGUIUtility.TempContent("Layer"), target1.layer);

            if (EditorGUI.EndChangeCheck())
            {
                GameObjectUtility.ShouldIncludeChildren shouldIncludeChildren = GameObjectUtility.DisplayUpdateChildrenDialogIfNeeded(this.targets.OfType <GameObject>(), "Change Layer", "Do you want to set layer to " + InternalEditorUtility.GetLayerName(layer) + " for all child objects as well?");
                if (shouldIncludeChildren != GameObjectUtility.ShouldIncludeChildren.Cancel)
                {
                    this.m_Layer.intValue = layer;
                    this.SetLayer(layer, shouldIncludeChildren == GameObjectUtility.ShouldIncludeChildren.IncludeChildren);
                }
            }
            EditorGUI.EndProperty();
            if (this.m_HasInstance && !EditorApplication.isPlayingOrWillChangePlaymode)
            {
                float      width3    = (float)(((double)width1 - 52.0 - 5.0) / 3.0);
                Rect       position2 = new Rect((float)(52.0 + (double)width3 * 0.0), 44f + y, width3, 15f);
                Rect       position3 = new Rect((float)(52.0 + (double)width3 * 1.0), 44f + y, width3, 15f);
                Rect       position4 = new Rect((float)(52.0 + (double)width3 * 2.0), 44f + y, width3, 15f);
                Rect       position5 = new Rect(52f, 44f + y, width3 * 3f, 15f);
                GUIContent content   = this.targets.Length <= 1 ? GameObjectInspector.s_styles.goTypeLabel[(int)prefabType] : GameObjectInspector.s_styles.goTypeLabelMultiple;
                if (content != null)
                {
                    float x = GUI.skin.label.CalcSize(content).x;
                    if (prefabType == PrefabType.DisconnectedModelPrefabInstance || prefabType == PrefabType.MissingPrefabInstance || prefabType == PrefabType.DisconnectedPrefabInstance)
                    {
                        GUI.contentColor = GUI.skin.GetStyle("CN StatusWarn").normal.textColor;
                        if (prefabType == PrefabType.MissingPrefabInstance)
                        {
                            GUI.Label(new Rect(52f, 44f + y, (float)((double)width1 - 52.0 - 5.0), 18f), content, EditorStyles.whiteLabel);
                        }
                        else
                        {
                            GUI.Label(new Rect((float)(52.0 - (double)x - 5.0), 44f + y, (float)((double)width1 - 52.0 - 5.0), 18f), content, EditorStyles.whiteLabel);
                        }
                        GUI.contentColor = Color.white;
                    }
                    else
                    {
                        GUI.Label(new Rect((float)(52.0 - (double)x - 5.0), 44f + y, x, 18f), content);
                    }
                }
                if (this.targets.Length > 1)
                {
                    GUI.Label(position5, "Instance Management Disabled", GameObjectInspector.s_styles.instanceManagementInfo);
                }
                else
                {
                    if (prefabType != PrefabType.MissingPrefabInstance && GUI.Button(position2, "Select", (GUIStyle)"MiniButtonLeft"))
                    {
                        Selection.activeObject = PrefabUtility.GetPrefabParent(this.target);
                        EditorGUIUtility.PingObject(Selection.activeObject);
                    }
                    if ((prefabType == PrefabType.DisconnectedModelPrefabInstance || prefabType == PrefabType.DisconnectedPrefabInstance) && GUI.Button(position3, "Revert", (GUIStyle)"MiniButtonMid"))
                    {
                        Undo.RegisterFullObjectHierarchyUndo((UnityEngine.Object)target1, "Revert to prefab");
                        PrefabUtility.ReconnectToLastPrefab(target1);
                        PrefabUtility.RevertPrefabInstance(target1);
                        this.CalculatePrefabStatus();
                        Undo.RegisterCreatedObjectUndo((UnityEngine.Object)target1, "Reconnect prefab");
                        GUIUtility.ExitGUI();
                    }
                    bool enabled2 = GUI.enabled;
                    GUI.enabled = GUI.enabled && !AnimationMode.InAnimationMode();
                    if ((prefabType == PrefabType.ModelPrefabInstance || prefabType == PrefabType.PrefabInstance) && GUI.Button(position3, "Revert", (GUIStyle)"MiniButtonMid"))
                    {
                        Undo.RegisterFullObjectHierarchyUndo((UnityEngine.Object)target1, "Revert Prefab Instance");
                        PrefabUtility.RevertPrefabInstance(target1);
                        this.CalculatePrefabStatus();
                        Undo.RegisterCreatedObjectUndo((UnityEngine.Object)target1, "Revert prefab");
                        GUIUtility.ExitGUI();
                    }
                    if (prefabType == PrefabType.PrefabInstance || prefabType == PrefabType.DisconnectedPrefabInstance)
                    {
                        GameObject prefabInstanceRoot = PrefabUtility.FindValidUploadPrefabInstanceRoot(target1);
                        GUI.enabled = (UnityEngine.Object)prefabInstanceRoot != (UnityEngine.Object)null && !AnimationMode.InAnimationMode();
                        if (GUI.Button(position4, "Apply", (GUIStyle)"MiniButtonRight"))
                        {
                            UnityEngine.Object prefabParent = PrefabUtility.GetPrefabParent((UnityEngine.Object)prefabInstanceRoot);
                            if (Provider.PromptAndCheckoutIfNeeded(new string[1] {
                                AssetDatabase.GetAssetPath(prefabParent)
                            }, "The version control requires you to check out the prefab before applying changes."))
                            {
                                PrefabUtility.ReplacePrefab(prefabInstanceRoot, prefabParent, ReplacePrefabOptions.ConnectToPrefab);
                                this.CalculatePrefabStatus();
                                EditorSceneManager.MarkSceneDirty(prefabInstanceRoot.scene);
                                GUIUtility.ExitGUI();
                            }
                        }
                    }
                    GUI.enabled = enabled2;
                    if ((prefabType == PrefabType.DisconnectedModelPrefabInstance || prefabType == PrefabType.ModelPrefabInstance) && GUI.Button(position4, "Open", (GUIStyle)"MiniButtonRight"))
                    {
                        AssetDatabase.OpenAsset(PrefabUtility.GetPrefabParent(this.target));
                        GUIUtility.ExitGUI();
                    }
                }
            }
            EditorGUI.EndDisabledGroup();
            this.serializedObject.ApplyModifiedProperties();
            return(true);
        }
        private static float GetRenderableCenterRecurse(ref Vector3 center, GameObject go, int depth, int minDepth, int maxDepth)
        {
            float result;

            if (depth > maxDepth)
            {
                result = 0f;
            }
            else
            {
                float num = 0f;
                if (depth > minDepth)
                {
                    MeshRenderer        meshRenderer        = go.GetComponent(typeof(MeshRenderer)) as MeshRenderer;
                    MeshFilter          x                   = go.GetComponent(typeof(MeshFilter)) as MeshFilter;
                    SkinnedMeshRenderer skinnedMeshRenderer = go.GetComponent(typeof(SkinnedMeshRenderer)) as SkinnedMeshRenderer;
                    SpriteRenderer      spriteRenderer      = go.GetComponent(typeof(SpriteRenderer)) as SpriteRenderer;
                    if (meshRenderer == null && x == null && skinnedMeshRenderer == null && spriteRenderer == null)
                    {
                        num     = 1f;
                        center += go.transform.position;
                    }
                    else if (meshRenderer != null && x != null)
                    {
                        if (Vector3.Distance(meshRenderer.bounds.center, go.transform.position) < 0.01f)
                        {
                            num     = 1f;
                            center += go.transform.position;
                        }
                    }
                    else if (skinnedMeshRenderer != null)
                    {
                        if (Vector3.Distance(skinnedMeshRenderer.bounds.center, go.transform.position) < 0.01f)
                        {
                            num     = 1f;
                            center += go.transform.position;
                        }
                    }
                    else if (spriteRenderer != null)
                    {
                        if (Vector3.Distance(spriteRenderer.bounds.center, go.transform.position) < 0.01f)
                        {
                            num     = 1f;
                            center += go.transform.position;
                        }
                    }
                }
                depth++;
                IEnumerator enumerator = go.transform.GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        Transform transform = (Transform)enumerator.Current;
                        num += GameObjectInspector.GetRenderableCenterRecurse(ref center, transform.gameObject, depth, minDepth, maxDepth);
                    }
                }
                finally
                {
                    IDisposable disposable;
                    if ((disposable = (enumerator as IDisposable)) != null)
                    {
                        disposable.Dispose();
                    }
                }
                result = num;
            }
            return(result);
        }
        internal bool DrawInspector(Rect contentRect)
        {
            if (GameObjectInspector.s_styles == null)
            {
                GameObjectInspector.s_styles = new GameObjectInspector.Styles();
            }
            base.serializedObject.Update();
            GameObject gameObject = this.target as GameObject;

            EditorGUIUtility.labelWidth = 52f;
            bool enabled = GUI.enabled;

            GUI.enabled = true;
            GUI.Label(new Rect(contentRect.x, contentRect.y, contentRect.width, contentRect.height + 3f), GUIContent.none, EditorStyles.inspectorBig);
            GUI.enabled = enabled;
            float      width      = contentRect.width;
            float      y          = contentRect.y;
            GUIContent gUIContent = null;
            PrefabType prefabType = PrefabType.None;

            if (this.m_AllOfSamePrefabType)
            {
                prefabType = PrefabUtility.GetPrefabType(gameObject);
                switch (prefabType)
                {
                case PrefabType.None:
                    gUIContent = GameObjectInspector.s_styles.goIcon;
                    break;

                case PrefabType.Prefab:
                case PrefabType.PrefabInstance:
                case PrefabType.DisconnectedPrefabInstance:
                    gUIContent = GameObjectInspector.s_styles.prefabIcon;
                    break;

                case PrefabType.ModelPrefab:
                case PrefabType.ModelPrefabInstance:
                case PrefabType.DisconnectedModelPrefabInstance:
                    gUIContent = GameObjectInspector.s_styles.modelIcon;
                    break;

                case PrefabType.MissingPrefabInstance:
                    gUIContent = GameObjectInspector.s_styles.prefabIcon;
                    break;
                }
            }
            else
            {
                gUIContent = GameObjectInspector.s_styles.typelessIcon;
            }
            EditorGUI.ObjectIconDropDown(new Rect(3f, 4f + y, 24f, 24f), base.targets, true, gUIContent.image as Texture2D, this.m_Icon);
            using (new EditorGUI.DisabledScope(prefabType == PrefabType.ModelPrefab))
            {
                EditorGUI.PropertyField(new Rect(34f, 4f + y, 14f, 14f), this.m_IsActive, GUIContent.none);
                float num    = GameObjectInspector.s_styles.staticFieldToggleWidth + 15f;
                float width2 = width - 52f - num - 5f;
                EditorGUI.DelayedTextField(new Rect(52f, 4f + y + 1f, width2, 16f), this.m_Name, GUIContent.none);
                Rect rect = new Rect(width - num, 4f + y, GameObjectInspector.s_styles.staticFieldToggleWidth, 16f);
                EditorGUI.BeginProperty(rect, GUIContent.none, this.m_StaticEditorFlags);
                EditorGUI.BeginChangeCheck();
                Rect position = rect;
                EditorGUI.showMixedValue |= GameObjectInspector.ShowMixedStaticEditorFlags((StaticEditorFlags)this.m_StaticEditorFlags.intValue);
                Event     current = Event.current;
                EventType type    = current.type;
                bool      flag    = current.type == EventType.MouseDown && current.button != 0;
                if (flag)
                {
                    current.type = EventType.Ignore;
                }
                bool flagValue = EditorGUI.ToggleLeft(position, "Static", gameObject.isStatic);
                if (flag)
                {
                    current.type = type;
                }
                EditorGUI.showMixedValue = false;
                if (EditorGUI.EndChangeCheck())
                {
                    SceneModeUtility.SetStaticFlags(base.targets, -1, flagValue);
                    base.serializedObject.SetIsDifferentCacheDirty();
                }
                EditorGUI.EndProperty();
                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = this.m_StaticEditorFlags.hasMultipleDifferentValues;
                int  changedFlags;
                bool flagValue2;
                EditorGUI.EnumMaskField(new Rect(rect.x + GameObjectInspector.s_styles.staticFieldToggleWidth, rect.y, 10f, 14f), GameObjectUtility.GetStaticEditorFlags(gameObject), GameObjectInspector.s_styles.staticDropdown, out changedFlags, out flagValue2);
                EditorGUI.showMixedValue = false;
                if (EditorGUI.EndChangeCheck())
                {
                    SceneModeUtility.SetStaticFlags(base.targets, changedFlags, flagValue2);
                    base.serializedObject.SetIsDifferentCacheDirty();
                }
                float num2 = 4f;
                float num3 = 4f;
                EditorGUIUtility.fieldWidth = (width - num2 - 52f - GameObjectInspector.s_styles.layerFieldWidth - num3) / 2f;
                string tag = null;
                try
                {
                    tag = gameObject.tag;
                }
                catch (Exception)
                {
                    tag = "Undefined";
                }
                EditorGUIUtility.labelWidth = GameObjectInspector.s_styles.tagFieldWidth;
                Rect rect2 = new Rect(52f - EditorGUIUtility.labelWidth, 24f + y, EditorGUIUtility.labelWidth + EditorGUIUtility.fieldWidth, 16f);
                EditorGUI.BeginProperty(rect2, GUIContent.none, this.m_Tag);
                EditorGUI.BeginChangeCheck();
                string text = EditorGUI.TagField(rect2, EditorGUIUtility.TempContent("Tag"), tag);
                if (EditorGUI.EndChangeCheck())
                {
                    this.m_Tag.stringValue = text;
                    Undo.RecordObjects(base.targets, "Change Tag of " + this.targetTitle);
                    UnityEngine.Object[] targets = base.targets;
                    for (int i = 0; i < targets.Length; i++)
                    {
                        UnityEngine.Object @object = targets[i];
                        (@object as GameObject).tag = text;
                    }
                }
                EditorGUI.EndProperty();
                EditorGUIUtility.labelWidth = GameObjectInspector.s_styles.layerFieldWidth;
                rect2 = new Rect(52f + EditorGUIUtility.fieldWidth + num2, 24f + y, EditorGUIUtility.labelWidth + EditorGUIUtility.fieldWidth, 16f);
                EditorGUI.BeginProperty(rect2, GUIContent.none, this.m_Layer);
                EditorGUI.BeginChangeCheck();
                int num4 = EditorGUI.LayerField(rect2, EditorGUIUtility.TempContent("Layer"), gameObject.layer);
                if (EditorGUI.EndChangeCheck())
                {
                    GameObjectUtility.ShouldIncludeChildren shouldIncludeChildren = GameObjectUtility.DisplayUpdateChildrenDialogIfNeeded(base.targets.OfType <GameObject>(), "Change Layer", "Do you want to set layer to " + InternalEditorUtility.GetLayerName(num4) + " for all child objects as well?");
                    if (shouldIncludeChildren != GameObjectUtility.ShouldIncludeChildren.Cancel)
                    {
                        this.m_Layer.intValue = num4;
                        this.SetLayer(num4, shouldIncludeChildren == GameObjectUtility.ShouldIncludeChildren.IncludeChildren);
                    }
                }
                EditorGUI.EndProperty();
                if (this.m_HasInstance)
                {
                    using (new EditorGUI.DisabledScope(EditorApplication.isPlayingOrWillChangePlaymode))
                    {
                        float      num5        = (width - 52f - 5f) / 3f;
                        Rect       position2   = new Rect(52f + num5 * 0f, 44f + y, num5, 15f);
                        Rect       position3   = new Rect(52f + num5 * 1f, 44f + y, num5, 15f);
                        Rect       position4   = new Rect(52f + num5 * 2f, 44f + y, num5, 15f);
                        Rect       position5   = new Rect(52f, 44f + y, num5 * 3f, 15f);
                        GUIContent gUIContent2 = (base.targets.Length <= 1) ? GameObjectInspector.s_styles.goTypeLabel[(int)prefabType] : GameObjectInspector.s_styles.goTypeLabelMultiple;
                        if (gUIContent2 != null)
                        {
                            float x = GUI.skin.label.CalcSize(gUIContent2).x;
                            if (prefabType == PrefabType.DisconnectedModelPrefabInstance || prefabType == PrefabType.MissingPrefabInstance || prefabType == PrefabType.DisconnectedPrefabInstance)
                            {
                                GUI.contentColor = GUI.skin.GetStyle("CN StatusWarn").normal.textColor;
                                if (prefabType == PrefabType.MissingPrefabInstance)
                                {
                                    GUI.Label(new Rect(52f, 44f + y, width - 52f - 5f, 18f), gUIContent2, EditorStyles.whiteLabel);
                                }
                                else
                                {
                                    GUI.Label(new Rect(52f - x - 5f, 44f + y, width - 52f - 5f, 18f), gUIContent2, EditorStyles.whiteLabel);
                                }
                                GUI.contentColor = Color.white;
                            }
                            else
                            {
                                Rect position6 = new Rect(52f - x - 5f, 44f + y, x, 18f);
                                GUI.Label(position6, gUIContent2);
                            }
                        }
                        if (base.targets.Length > 1)
                        {
                            GUI.Label(position5, "Instance Management Disabled", GameObjectInspector.s_styles.instanceManagementInfo);
                        }
                        else
                        {
                            if (prefabType != PrefabType.MissingPrefabInstance && GUI.Button(position2, "Select", "MiniButtonLeft"))
                            {
                                Selection.activeObject = PrefabUtility.GetPrefabParent(this.target);
                                EditorGUIUtility.PingObject(Selection.activeObject);
                            }
                            if ((prefabType == PrefabType.DisconnectedModelPrefabInstance || prefabType == PrefabType.DisconnectedPrefabInstance) && GUI.Button(position3, "Revert", "MiniButtonMid"))
                            {
                                Undo.RegisterFullObjectHierarchyUndo(gameObject, "Revert to prefab");
                                PrefabUtility.ReconnectToLastPrefab(gameObject);
                                PrefabUtility.RevertPrefabInstance(gameObject);
                                this.CalculatePrefabStatus();
                                Undo.RegisterCreatedObjectUndo(gameObject, "Reconnect prefab");
                                GUIUtility.ExitGUI();
                            }
                            using (new EditorGUI.DisabledScope(AnimationMode.InAnimationMode()))
                            {
                                if ((prefabType == PrefabType.ModelPrefabInstance || prefabType == PrefabType.PrefabInstance) && GUI.Button(position3, "Revert", "MiniButtonMid"))
                                {
                                    Undo.RegisterFullObjectHierarchyUndo(gameObject, "Revert Prefab Instance");
                                    PrefabUtility.RevertPrefabInstance(gameObject);
                                    this.CalculatePrefabStatus();
                                    Undo.RegisterCreatedObjectUndo(gameObject, "Revert prefab");
                                    GUIUtility.ExitGUI();
                                }
                                if (prefabType == PrefabType.PrefabInstance || prefabType == PrefabType.DisconnectedPrefabInstance)
                                {
                                    GameObject gameObject2 = PrefabUtility.FindValidUploadPrefabInstanceRoot(gameObject);
                                    GUI.enabled = (gameObject2 != null && !AnimationMode.InAnimationMode());
                                    if (GUI.Button(position4, "Apply", "MiniButtonRight"))
                                    {
                                        UnityEngine.Object prefabParent = PrefabUtility.GetPrefabParent(gameObject2);
                                        string             assetPath    = AssetDatabase.GetAssetPath(prefabParent);
                                        bool flag2 = Provider.PromptAndCheckoutIfNeeded(new string[]
                                        {
                                            assetPath
                                        }, "The version control requires you to check out the prefab before applying changes.");
                                        if (flag2)
                                        {
                                            PrefabUtility.ReplacePrefab(gameObject2, prefabParent, ReplacePrefabOptions.ConnectToPrefab);
                                            this.CalculatePrefabStatus();
                                            EditorSceneManager.MarkSceneDirty(gameObject2.scene);
                                            GUIUtility.ExitGUI();
                                        }
                                    }
                                }
                            }
                            if ((prefabType == PrefabType.DisconnectedModelPrefabInstance || prefabType == PrefabType.ModelPrefabInstance) && GUI.Button(position4, "Open", "MiniButtonRight"))
                            {
                                AssetDatabase.OpenAsset(PrefabUtility.GetPrefabParent(this.target));
                                GUIUtility.ExitGUI();
                            }
                        }
                    }
                }
            }
            base.serializedObject.ApplyModifiedProperties();
            return(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();
                }
            }
        }