void SetActiveEntry(int selectedIndex)
 {
     m_ListViewMessage.row         = -1;
     m_ListViewMessage.scrollPos.y = 0;
     if (selectedIndex != -1)
     {
         var instanceID = LogEntries.wrapped.SetSelectedEntry(selectedIndex);
         // ping object referred by the log entry
         if (m_ActiveInstanceID != instanceID)
         {
             m_ActiveInstanceID = instanceID;
             if (instanceID != 0)
             {
                 EditorGUIUtility.PingObject(instanceID);
             }
         }
     }
 }
        private void DoPrefabButtons()
        {
            if (!m_IsPrefabInstanceAnyRoot || m_IsAsset)
            {
                return;
            }

            using (new EditorGUI.DisabledScope(m_PlayModeObjects))
            {
                EditorGUILayout.BeginHorizontal(Styles.prefabButtonsHorizontalLayout);

                // Prefab information
                PrefabAssetType      singlePrefabType     = PrefabUtility.GetPrefabAssetType(target);
                PrefabInstanceStatus singleInstanceStatus = PrefabUtility.GetPrefabInstanceStatus(target);
                GUIContent           prefixLabel;
                if (targets.Length > 1)
                {
                    prefixLabel = Styles.goTypeLabelMultiple;
                }
                else
                {
                    prefixLabel = Styles.goTypeLabel[(int)singlePrefabType, (int)singleInstanceStatus];
                }

                if (prefixLabel != null)
                {
                    EditorGUILayout.BeginHorizontal(GUILayout.Width(kIconSize + Styles.tagFieldWidth));
                    GUILayout.FlexibleSpace();
                    if (m_IsDisconnected || m_IsMissing)
                    {
                        GUI.contentColor = GUI.skin.GetStyle("CN StatusWarn").normal.textColor;
                        DoPrefixLabel(prefixLabel, EditorStyles.whiteLabel);
                        GUI.contentColor = Color.white;
                    }
                    else
                    {
                        DoPrefixLabel(prefixLabel, EditorStyles.label);
                    }
                    EditorGUILayout.EndHorizontal();
                }

                if (!m_IsMissing)
                {
                    using (new EditorGUI.DisabledScope(targets.Length > 1))
                    {
                        if (singlePrefabType == PrefabAssetType.Model)
                        {
                            // Open Model Prefab
                            if (GUILayout.Button(Styles.openModel, EditorStyles.miniButtonLeft))
                            {
                                GameObject asset = PrefabUtility.GetOriginalSourceOrVariantRoot(target);
                                AssetDatabase.OpenAsset(asset);
                                GUIUtility.ExitGUI();
                            }
                        }
                        else
                        {
                            // Open non-Model Prefab
                            using (new EditorGUI.DisabledScope(m_ImmutableSourceAsset))
                            {
                                if (GUILayout.Button(m_OpenPrefabContent, EditorStyles.miniButtonLeft))
                                {
                                    GameObject asset           = PrefabUtility.GetOriginalSourceOrVariantRoot(target);
                                    var        prefabStageMode = PrefabStageUtility.GetPrefabStageModeFromModifierKeys();
                                    PrefabStageUtility.OpenPrefab(AssetDatabase.GetAssetPath(asset), (GameObject)target, prefabStageMode, StageNavigationManager.Analytics.ChangeType.EnterViaInstanceInspectorOpenButton);
                                    GUIUtility.ExitGUI();
                                }
                            }
                        }
                    }

                    // Select prefab
                    if (GUILayout.Button(Styles.selectString, EditorStyles.miniButtonRight))
                    {
                        HashSet <GameObject> selectedAssets = new HashSet <GameObject>();
                        for (int i = 0; i < targets.Length; i++)
                        {
                            GameObject prefabGo = PrefabUtility.GetOriginalSourceOrVariantRoot(targets[i]);

                            // Because of legacy prefab references we have to have this extra step
                            // to make sure we ping the prefab asset correctly.
                            // Reason is that scene files created prior to making prefabs CopyAssets
                            // will reference prefabs as if they are serialized assets. Those references
                            // works fine but we are not able to ping objects loaded directly from the asset
                            // file, so we have to make sure we ping the metadata version of the prefab.
                            var assetPath = AssetDatabase.GetAssetPath(prefabGo);
                            selectedAssets.Add((GameObject)AssetDatabase.LoadMainAssetAtPath(assetPath));
                        }

                        Selection.objects = selectedAssets.ToArray();
                        if (Selection.gameObjects.Length == 1)
                        {
                            EditorGUIUtility.PingObject(Selection.activeObject);
                        }
                    }

                    // Should be EditorGUILayout.Space, except it does not have ExpandWidth set to false.
                    // Maybe we can change that?
                    GUILayoutUtility.GetRect(6, 6, GUILayout.ExpandWidth(false));

                    // Reserve space regardless of whether the button is there or not to avoid jumps in button sizes.
                    Rect rect = GUILayoutUtility.GetRect(Styles.overridesContent, Styles.overridesDropdown);
                    if (m_IsPrefabInstanceOutermostRoot)
                    {
                        if (EditorGUI.DropdownButton(rect, Styles.overridesContent, FocusType.Passive))
                        {
                            if (targets.Length > 1)
                            {
                                PopupWindow.Show(rect, new PrefabOverridesWindow(targets.Select(e => (GameObject)e).ToArray()));
                            }
                            else
                            {
                                PopupWindow.Show(rect, new PrefabOverridesWindow((GameObject)target));
                            }
                            GUIUtility.ExitGUI();
                        }
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
        }
        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);
            EditorGUI.BeginDisabledGroup(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.BeginChangeCheck();
            EditorGUI.showMixedValue = this.m_Name.hasMultipleDifferentValues;
            string name = EditorGUI.DelayedTextField(new Rect(52f, 4f + y + 1f, width2, 16f), gameObject.name, null, EditorStyles.textField);

            EditorGUI.showMixedValue = false;
            if (EditorGUI.EndChangeCheck())
            {
                UnityEngine.Object[] targets = base.targets;
                for (int i = 0; i < targets.Length; i++)
                {
                    UnityEngine.Object @object = targets[i];
                    ObjectNames.SetNameSmart(@object as GameObject, name);
                }
            }
            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[] targets2 = base.targets;
                for (int j = 0; j < targets2.Length; j++)
                {
                    UnityEngine.Object object2 = targets2[j];
                    (object2 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 && !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();
                    }
                    bool enabled2 = GUI.enabled;
                    GUI.enabled = (GUI.enabled && !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();
                        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 checkout the prefab before applying changes.");
                            if (flag2)
                            {
                                PrefabUtility.ReplacePrefab(gameObject2, prefabParent, ReplacePrefabOptions.ConnectToPrefab);
                                this.CalculatePrefabStatus();
                                GUIUtility.ExitGUI();
                            }
                        }
                    }
                    GUI.enabled = enabled2;
                    if ((prefabType == PrefabType.DisconnectedModelPrefabInstance || prefabType == PrefabType.ModelPrefabInstance) && GUI.Button(position4, "Open", "MiniButtonRight"))
                    {
                        AssetDatabase.OpenAsset(PrefabUtility.GetPrefabParent(this.target));
                        GUIUtility.ExitGUI();
                    }
                }
            }
            EditorGUI.EndDisabledGroup();
            base.serializedObject.ApplyModifiedProperties();
            return(true);
        }
        public void StageHeaderGUI(Rect rect)
        {
            var stage = currentStage;

            if (stage == null || !stage.isValid)
            {
                return;
            }

            if (m_StageHeaderContent == GUIContent.none || m_LastStageUnsavedChangesState == stage.hasUnsavedChanges)
            {
                CacheStageHeaderContent();
            }
            m_LastStageUnsavedChangesState = stage.hasUnsavedChanges;

            // Background
            GUI.Label(rect, GUIContent.none, Styles.stageHeaderBg);

            // Back button
            if (Event.current.type == EventType.Repaint)
            {
                Rect renderRect = new Rect(
                    rect.x + Styles.leftArrow.margin.left,
                    rect.y + (rect.height - Styles.leftArrow.fixedHeight) / 2,
                    Styles.leftArrow.fixedWidth,
                    Styles.leftArrow.fixedHeight);
                Styles.leftArrow.Draw(renderRect, GUIContent.none, false, false, false, false);
            }
            Rect interactionRect = new Rect(
                rect.x,
                rect.y,
                Styles.leftArrow.fixedWidth + Styles.leftArrow.margin.horizontal,
                rect.height);

            if (GUI.Button(interactionRect, GUIContent.none, GUIStyle.none))
            {
                StageNavigationManager.instance.NavigateBack(StageNavigationManager.Analytics.ChangeType.NavigateBackViaHierarchyHeaderLeftArrow);
            }

            // Icon and name
            EditorGUIUtility.SetIconSize(new Vector2(16, 16));
            float width           = TreeViewGUI.Styles.lineBoldStyle.CalcSize(m_StageHeaderContent).x;
            float xStart          = Styles.leftArrow.margin.left + Styles.leftArrow.fixedWidth;
            float space           = rect.width;
            float offsetFromStart = Mathf.Max(xStart, (space - width) / 2);
            Rect  labelRect       = new Rect(offsetFromStart, rect.y + 2, rect.width - xStart, 20);

            if (GUI.Button(labelRect, m_StageHeaderContent, stage.isAssetMissing ? BreadcrumbBar.DefaultStyles.labelBoldMissing : BreadcrumbBar.DefaultStyles.labelBold))
            {
                EditorGUIUtility.PingObject(AssetDatabase.LoadMainAssetAtPath(stage.assetPath));
            }
            EditorGUIUtility.SetIconSize(Vector2.zero);

            // Version control overlay icons
            if (VersionControl.Provider.isActive)
            {
                Rect overlayRect = labelRect;
                overlayRect.width  = 16;
                overlayRect.y     += (overlayRect.height - 16) / 2;
                overlayRect.height = 16;

                // The source asset can have been deleted while open in stage so the library object can be null here (case 1086613)
                var asset = AssetDatabase.LoadMainAssetAtPath(stage.assetPath);
                if (asset != null)
                {
                    AssetsTreeViewGUI.OnIconOverlayGUI(asset.GetInstanceID(), overlayRect, true);
                }
            }
        }
        private void DrawCurrentEvent(Rect rect, FrameDebuggerEvent[] descs)
        {
            int num = FrameDebuggerUtility.limit - 1;

            if (num >= 0 && num < descs.Length)
            {
                GUILayout.BeginArea(rect);
                FrameDebuggerEvent     frameDebuggerEvent = descs[num];
                FrameDebuggerEventData frameDebuggerEventData;
                bool frameEventData = FrameDebuggerUtility.GetFrameEventData(num, out frameDebuggerEventData);
                if (frameEventData)
                {
                    this.DrawRenderTargetControls(frameDebuggerEventData);
                }
                GUILayout.Label(string.Format("Event #{0}: {1}", num + 1, FrameDebuggerWindow.s_FrameEventTypeNames[(int)frameDebuggerEvent.type]), EditorStyles.boldLabel, new GUILayoutOption[0]);
                if (FrameDebuggerUtility.IsRemoteEnabled() && FrameDebuggerUtility.receivingRemoteFrameEventData)
                {
                    GUILayout.Label("Receiving frame event data...", new GUILayoutOption[0]);
                }
                else if (frameEventData && (frameDebuggerEventData.vertexCount > 0 || frameDebuggerEventData.indexCount > 0))
                {
                    Shader shader          = frameDebuggerEventData.shader;
                    int    shaderPassIndex = frameDebuggerEventData.shaderPassIndex;
                    GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                    if (GUILayout.Button(string.Concat(new object[]
                    {
                        "Shader: ",
                        frameDebuggerEventData.shaderName,
                        " pass #",
                        shaderPassIndex
                    }), GUI.skin.label, new GUILayoutOption[]
                    {
                        GUILayout.ExpandWidth(false)
                    }))
                    {
                        EditorGUIUtility.PingObject(shader);
                        Event.current.Use();
                    }
                    GUILayout.Label(frameDebuggerEventData.shaderKeywords, EditorStyles.miniLabel, new GUILayoutOption[0]);
                    GUILayout.EndHorizontal();
                    this.DrawStates(frameDebuggerEventData);
                    GUILayout.Space(15f);
                    this.m_AdditionalInfo = (ShowAdditionalInfo)GUILayout.Toolbar((int)this.m_AdditionalInfo, this.m_AdditionalInfoGuiContents, new GUILayoutOption[0]);
                    ShowAdditionalInfo additionalInfo = this.m_AdditionalInfo;
                    if (additionalInfo != ShowAdditionalInfo.Preview)
                    {
                        if (additionalInfo == ShowAdditionalInfo.ShaderProperties)
                        {
                            if (frameEventData)
                            {
                                this.DrawShaderProperties(frameDebuggerEventData.shaderProperties);
                            }
                        }
                    }
                    else if (frameEventData)
                    {
                        if (!this.DrawEventMesh(frameDebuggerEventData))
                        {
                            GUILayout.Label("Vertices: " + frameDebuggerEventData.vertexCount, new GUILayoutOption[0]);
                            GUILayout.Label("Indices: " + frameDebuggerEventData.indexCount, new GUILayoutOption[0]);
                        }
                    }
                }
                GUILayout.EndArea();
            }
        }
        public override void OnGUI(Rect rect)
        {
            if (editorWindow.position.y != targetPositionY)
            {
                editorWindow.position = new Rect(editorWindow.position)
                {
                    y = targetPositionY
                }
            }
            ;

            // Escape closes the window
            if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Escape)
            {
                editorWindow.Close();
                GUIUtility.ExitGUI();
            }

            if (!DrawHeader())
            {
                return;
            }

            float height = k_HeaderHeight;

            if (target.isVariant)
            {
                height += DrawVariantHierarchy();
            }

            height += DrawChildrenLabel(height);

            if (displayChildren)
            {
                DrawChildren(height);
            }

            if (materialEditor.convertState == ConvertAction.Flatten)
            {
                materialEditor.convertState = ConvertAction.None;
                Undo.RecordObject(target, "Flatten Material Variant");
                target.parent = null;
                Init();
            }
        }

        bool DrawHeader()
        {
            Rect headerRect = GUILayoutUtility.GetRect(20, windowWidth, k_HeaderHeight, k_HeaderHeight);

            EditorGUI.DrawRect(headerRect, Colors.headerBackground);

            var   headerLabel = target.isVariant ? Styles.variantLabel : Styles.instanceLabel;
            float labelSize   = Styles.boldRightAligned.CalcSize(headerLabel).x;

            Rect labelRect   = new Rect(k_OffsetX, headerRect.y + k_Padding, labelSize, EditorGUIUtility.singleLineHeight);
            Rect contentRect = new Rect(labelRect.x + labelRect.width + k_Padding, labelRect.y, windowWidth, labelRect.height);

            GUI.Label(labelRect, headerLabel, Styles.boldRightAligned);
            DoObjectLabel(contentRect, target, EditorStyles.boldLabel);

            labelRect.y = labelRect.height + 2 * k_Padding;
            if (materialEditor.convertState == ConvertAction.None)
            {
                int result;
                labelRect.width = k_ConvertLabelWidth;
                using (new EditorGUI.DisabledScope(!enabled))
                    result = EditorGUI.Popup(labelRect, target.isVariant ? 1 : 0, Styles.headerPopupOptions);
                if (result == 0 && target.isVariant)
                {
                    materialEditor.convertState = ConvertAction.Flatten;
                    targetPositionY             = singleLinePositionY;
                }
                if (result == 1 && !target.isVariant)
                {
                    materialEditor.convertState = ConvertAction.Convert;
                    targetPositionY             = singleLinePositionY + k_PositionShiftY;
                }
            }
            else if (materialEditor.convertState == ConvertAction.Convert)
            {
                GUI.enabled     = false;
                labelRect.width = 200f;
                EditorGUI.Button(labelRect, Styles.convertingLabel);
                GUI.enabled = true;

                // Conversion helper
                labelRect.y     = k_HeaderHeight;
                labelRect.width = windowWidth;
                EditorGUI.LabelField(labelRect, Styles.conversionHelpLabel);

                labelRect.x = windowWidth - 14;
                if (GUI.Button(labelRect, GUIContent.none, EditorStyles.toolbarSearchFieldCancelButton))
                {
                    materialEditor.convertState = ConvertAction.None;
                    targetPositionY             = singleLinePositionY;
                    materialEditor.Repaint();
                }

                labelRect.x = k_OffsetX;
                var oldLabelWidth = EditorGUIUtility.labelWidth;
                EditorGUIUtility.labelWidth = 70;
                EditorGUI.BeginChangeCheck();
                var parent = target.parent;
                materialEditor.ParentField(new Rect(k_OffsetX, labelRect.yMax + k_Padding, windowWidth - 2 * k_OffsetX, k_EntryHeight));
                if (EditorGUI.EndChangeCheck() && parent != target.parent)
                {
                    materialEditor.convertState = ConvertAction.None;
                    Init();
                }
                EditorGUIUtility.labelWidth = oldLabelWidth;
                return(false);
            }

            return(true);
        }

        float DrawVariantHierarchy()
        {
            // Draw table header
            Rect entryRect = new Rect(0, k_HeaderHeight, windowWidth, k_EntryHeight);

            EditorGUI.DrawRect(entryRect, Colors.rowBackground(0));

            var labelRect = entryRect;

            labelRect.x = k_TitleWidth;
            GUI.Label(labelRect, Styles.ancestorLabel, EditorStyles.miniLabel);

            labelRect.x = overridesX + k_Padding;
            GUI.Label(labelRect, Styles.overridesLabel, EditorStyles.miniLabel);

            labelRect.x = locksX + k_Padding;
            GUI.Label(labelRect, Styles.locksLabel, EditorStyles.miniLabel);

            float tableHeight = Mathf.Min(numRows, k_MaxTableRows) * k_EntryHeight + (namesWidth > maxNameWidth ? k_ScrollbarHeight : 0);
            float realHeight  = numRows * k_EntryHeight + (namesWidth > maxNameWidth ? k_ScrollbarHeight : 0);
            var   tableRect   = new Rect(0, k_HeaderHeight + k_EntryHeight, windowWidth - 1, tableHeight);

            scroll.y = GUI.BeginScrollView(tableRect, scroll, new Rect(tableRect)
            {
                width = tableRect.width - k_ScrollbarWidth, height = realHeight
            }).y;

            // Draw overrides and locks table
            int      i       = numRows;
            Material current = target;

            while (current != null)
            {
                entryRect.y = k_HeaderHeight + i * k_EntryHeight;
                EditorGUI.DrawRect(entryRect, Colors.rowBackground(i--));

                DisplayOverridesAndLocks(entryRect, current);
                current = current.parent;
            }

            var scrollRect = new Rect(k_TitleWidth, k_HeaderHeight + k_EntryHeight, Mathf.Min(namesWidth, maxNameWidth), numRows * k_EntryHeight);

            scroll.x = GUI.BeginScrollView(new Rect(scrollRect)
            {
                height = scrollRect.height + k_ScrollbarHeight
            }, scroll, new Rect(scrollRect)
            {
                width = namesWidth
            }).x;

            // Draw scrollable table
            i           = numRows;
            current     = target;
            entryRect.x = k_TitleWidth;
            while (i != 0)
            {
                entryRect.y = k_HeaderHeight + i-- *k_EntryHeight;

                if (current == null)
                {
                    GUI.Label(entryRect, EditorGUIUtility.TempContent("Missing (Material)"));
                    break;
                }
                DoObjectLabel(entryRect, current);
                current = current.parent;
            }

            GUI.EndScrollView();

            float height = tableHeight + k_EntryHeight;

            // Draw selected label
            labelRect.x     = k_OffsetX;
            labelRect.y     = k_HeaderHeight + numRows * k_EntryHeight;
            labelRect.width = k_TitleWidth - labelRect.x;
            GUI.Label(labelRect, Styles.selectedLabel);

            // Draw parent label
            labelRect.y = k_HeaderHeight + (numRows - 1) * k_EntryHeight;
            GUI.Label(labelRect, Styles.parentLabel);

            // Draw root label
            if (labelRect.y != k_HeaderHeight + k_EntryHeight)
            {
                labelRect.y = k_HeaderHeight + k_EntryHeight;
                GUI.Label(labelRect, Styles.rootLabel);
            }

            // Draw vertical splits
            Rect splitBar = new Rect(overridesX - k_SplitWidth, k_HeaderHeight, k_SplitWidth, (numRows + 1) * k_EntryHeight);

            EditorGUI.DrawRect(splitBar, Colors.headerBackground);
            splitBar.x = locksX - k_SplitWidth;
            EditorGUI.DrawRect(splitBar, Colors.headerBackground);

            GUI.EndScrollView();

            return(height);
        }

        float DrawChildrenLabel(float yMin)
        {
            var labelRect = new Rect(k_OffsetX, yMin, 100, k_EntryHeight);

            if (target.isVariant)
            {
                displayChildren = EditorGUI.Foldout(labelRect, displayChildren, Styles.childrenLabel, true);
            }
            else
            {
                EditorGUI.LabelField(labelRect, Styles.childrenLabel);
            }

            if (displayChildren)
            {
                if (listArea == null)
                {
                    InitListArea();
                }

                labelRect = new Rect(labelRect.x + 58 + (target.isVariant ? 12 : 0), labelRect.y + 2, k_SliderWidth, EditorGUI.kSingleLineHeight);
                if (results.Length != 0)
                {
                    EditorGUI.LabelField(labelRect, results.Length.ToString(), Styles.boldNumber);
                }

                EditorGUI.BeginChangeCheck();
                labelRect.x = windowWidth - k_OffsetX - k_SliderWidth;
                var newGridSize = (int)GUI.HorizontalSlider(labelRect, listArea.gridSize, listArea.minGridSize, listArea.maxGridSize);
                if (EditorGUI.EndChangeCheck())
                {
                    listArea.gridSize = newGridSize;
                }
            }

            return(k_EntryHeight);
        }

        void DrawChildren(float yMin)
        {
            var backgroundRect = new Rect(0, yMin, windowWidth, k_SearchHeight);

            GUI.Label(backgroundRect, GUIContent.none, Styles.searchBackground);

            EditorGUI.BeginChangeCheck();
            var searchRect = new Rect(k_OffsetX + k_Padding, backgroundRect.y + k_Padding, windowWidth - 2 * k_OffsetX - k_Padding, Styles.searchFieldStyle.fixedHeight);

            searchFilterString = EditorGUI.ToolbarSearchField(searchRect, searchFilterString, false);
            if (EditorGUI.EndChangeCheck())
            {
                debounce.Execute();
            }

            if (enumerator != null)
            {
                Search();
            }

            yMin = searchRect.height + (listArea.gridSize < k_MinIconSize ? 11f : 0f);
            var listRect = new Rect(k_Padding, searchRect.y + yMin, windowWidth - 2 * k_Padding, k_SearchHeight - yMin - k_Padding);

            int listKeyboardControlID = GUIUtility.GetControlID(FocusType.Keyboard);

            listArea.OnGUI(listRect, listKeyboardControlID);

            if (enumerator == null && results.Length == 0)
            {
                var labelRect = new Rect(noResultsX, backgroundRect.y + 69f, windowWidth, EditorGUI.kSingleLineHeight);
                EditorGUI.LabelField(backgroundRect, searchFilter.nameFilter.Length == 0 ? Styles.noChildrenLabel : Styles.noResultsLabel, Styles.centered);
            }
        }

        void InitListArea()
        {
            listArea = new ObjectListArea(s_ListAreaState, editorWindow, false)
            {
                allowDeselection      = true,
                allowMultiSelect      = false,
                allowRenaming         = false,
                allowBuiltinResources = true,
            };

            listArea.itemSelectedCallback += (bool doubleClicked) =>
            {
                if (listArea.GetSelection().Length == 0)
                {
                    return;
                }
                var selection = listArea.GetSelection()[0];
                GUIUtility.keyboardControl = GUIUtility.GetControlID(FocusType.Keyboard);
                if (doubleClicked)
                {
                    Selection.SetActiveObjectWithContext(EditorUtility.InstanceIDToObject(selection), null);
                    Event.current.Use();
                    editorWindow.Close();
                    GUIUtility.ExitGUI();
                }
                else
                {
                    EditorGUIUtility.PingObject(selection);
                    Event.current.Use();
                }
            };

            SearchFilterChanged();
        }
        internal bool DrawInspector(Rect contentRect)
        {
            int  num5;
            bool flag4;

            if (s_styles == null)
            {
                s_styles = new Styles();
            }
            base.serializedObject.Update();
            GameObject target = 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 goIcon = null;
            PrefabType none   = PrefabType.None;

            if (this.m_AllOfSamePrefabType)
            {
                none = PrefabUtility.GetPrefabType(target);
                switch (none)
                {
                case PrefabType.None:
                    goIcon = s_styles.goIcon;
                    break;

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

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

                case PrefabType.MissingPrefabInstance:
                    goIcon = s_styles.prefabIcon;
                    break;
                }
            }
            else
            {
                goIcon = s_styles.typelessIcon;
            }
            EditorGUI.ObjectIconDropDown(new Rect(3f, 4f + y, 24f, 24f), base.targets, true, goIcon.image as Texture2D, this.m_Icon);
            EditorGUI.BeginDisabledGroup(none == PrefabType.ModelPrefab);
            EditorGUI.PropertyField(new Rect(34f, 4f + y, 14f, 14f), this.m_IsActive, GUIContent.none);
            float num3 = s_styles.staticFieldToggleWidth + 15f;
            float num4 = ((width - 52f) - num3) - 5f;

            EditorGUI.DelayedTextField(new Rect(52f, (4f + y) + 1f, num4, 16f), this.m_Name, GUIContent.none);
            Rect totalPosition = new Rect(width - num3, 4f + y, s_styles.staticFieldToggleWidth, 16f);

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

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

            if (flag2)
            {
                current.type = EventType.Ignore;
            }
            bool flagValue = EditorGUI.ToggleLeft(position, "Static", target.isStatic);

            if (flag2)
            {
                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;
            EditorGUI.EnumMaskField(new Rect(totalPosition.x + s_styles.staticFieldToggleWidth, totalPosition.y, 10f, 14f), GameObjectUtility.GetStaticEditorFlags(target), s_styles.staticDropdown, out num5, out flag4);
            EditorGUI.showMixedValue = false;
            if (EditorGUI.EndChangeCheck())
            {
                SceneModeUtility.SetStaticFlags(base.targets, num5, flag4);
                base.serializedObject.SetIsDifferentCacheDirty();
            }
            float num6 = 4f;
            float num7 = 4f;

            EditorGUIUtility.fieldWidth = ((((width - num6) - 52f) - s_styles.layerFieldWidth) - num7) / 2f;
            string tag = null;

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

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

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

            if (EditorGUI.EndChangeCheck())
            {
                GameObjectUtility.ShouldIncludeChildren children = GameObjectUtility.DisplayUpdateChildrenDialogIfNeeded(base.targets.OfType <GameObject>(), "Change Layer", "Do you want to set layer to " + InternalEditorUtility.GetLayerName(layer) + " for all child objects as well?");
                if (children != GameObjectUtility.ShouldIncludeChildren.Cancel)
                {
                    this.m_Layer.intValue = layer;
                    this.SetLayer(layer, children == GameObjectUtility.ShouldIncludeChildren.IncludeChildren);
                }
            }
            EditorGUI.EndProperty();
            if (!this.m_HasInstance || EditorApplication.isPlayingOrWillChangePlaymode)
            {
                goto Label_093F;
            }
            float      num10    = ((width - 52f) - 5f) / 3f;
            Rect       rect4    = new Rect(52f + (num10 * 0f), 44f + y, num10, 15f);
            Rect       rect5    = new Rect(52f + (num10 * 1f), 44f + y, num10, 15f);
            Rect       rect6    = new Rect(52f + (num10 * 2f), 44f + y, num10, 15f);
            Rect       rect7    = new Rect(52f, 44f + y, num10 * 3f, 15f);
            GUIContent content2 = (base.targets.Length <= 1) ? s_styles.goTypeLabel[(int)none] : s_styles.goTypeLabelMultiple;

            if (content2 != null)
            {
                float x = GUI.skin.label.CalcSize(content2).x;
                switch (none)
                {
                case PrefabType.DisconnectedModelPrefabInstance:
                case PrefabType.MissingPrefabInstance:
                case PrefabType.DisconnectedPrefabInstance:
                    GUI.contentColor = GUI.skin.GetStyle("CN StatusWarn").normal.textColor;
                    if (none == PrefabType.MissingPrefabInstance)
                    {
                        GUI.Label(new Rect(52f, 44f + y, (width - 52f) - 5f, 18f), content2, EditorStyles.whiteLabel);
                    }
                    else
                    {
                        GUI.Label(new Rect((52f - x) - 5f, 44f + y, (width - 52f) - 5f, 18f), content2, EditorStyles.whiteLabel);
                    }
                    GUI.contentColor = Color.white;
                    goto Label_072D;
                }
                Rect rect8 = new Rect((52f - x) - 5f, 44f + y, x, 18f);
                GUI.Label(rect8, content2);
            }
Label_072D:
            if (base.targets.Length > 1)
            {
                GUI.Label(rect7, "Instance Management Disabled", s_styles.instanceManagementInfo);
            }
            else
            {
                if ((none != PrefabType.MissingPrefabInstance) && GUI.Button(rect4, "Select", "MiniButtonLeft"))
                {
                    Selection.activeObject = PrefabUtility.GetPrefabParent(this.target);
                    EditorGUIUtility.PingObject(Selection.activeObject);
                }
                if (((none == PrefabType.DisconnectedModelPrefabInstance) || (none == PrefabType.DisconnectedPrefabInstance)) && GUI.Button(rect5, "Revert", "MiniButtonMid"))
                {
                    Undo.RegisterFullObjectHierarchyUndo(target, "Revert to prefab");
                    PrefabUtility.ReconnectToLastPrefab(target);
                    PrefabUtility.RevertPrefabInstance(target);
                    this.CalculatePrefabStatus();
                    Undo.RegisterCreatedObjectUndo(target, "Reconnect prefab");
                    GUIUtility.ExitGUI();
                }
                bool flag5 = GUI.enabled;
                GUI.enabled = GUI.enabled && !AnimationMode.InAnimationMode();
                if (((none == PrefabType.ModelPrefabInstance) || (none == PrefabType.PrefabInstance)) && GUI.Button(rect5, "Revert", "MiniButtonMid"))
                {
                    Undo.RegisterFullObjectHierarchyUndo(target, "Revert Prefab Instance");
                    PrefabUtility.RevertPrefabInstance(target);
                    this.CalculatePrefabStatus();
                    Undo.RegisterCreatedObjectUndo(target, "Revert prefab");
                    GUIUtility.ExitGUI();
                }
                if ((none == PrefabType.PrefabInstance) || (none == PrefabType.DisconnectedPrefabInstance))
                {
                    GameObject source = PrefabUtility.FindValidUploadPrefabInstanceRoot(target);
                    GUI.enabled = (source != null) && !AnimationMode.InAnimationMode();
                    if (GUI.Button(rect6, "Apply", "MiniButtonRight"))
                    {
                        Object   prefabParent = PrefabUtility.GetPrefabParent(source);
                        string   assetPath    = AssetDatabase.GetAssetPath(prefabParent);
                        string[] assets       = new string[] { assetPath };
                        if (Provider.PromptAndCheckoutIfNeeded(assets, "The version control requires you to check out the prefab before applying changes."))
                        {
                            PrefabUtility.ReplacePrefab(source, prefabParent, ReplacePrefabOptions.ConnectToPrefab);
                            this.CalculatePrefabStatus();
                            GUIUtility.ExitGUI();
                        }
                    }
                }
                GUI.enabled = flag5;
                if (((none == PrefabType.DisconnectedModelPrefabInstance) || (none == PrefabType.ModelPrefabInstance)) && GUI.Button(rect6, "Open", "MiniButtonRight"))
                {
                    AssetDatabase.OpenAsset(PrefabUtility.GetPrefabParent(this.target));
                    GUIUtility.ExitGUI();
                }
            }
Label_093F:
            EditorGUI.EndDisabledGroup();
            base.serializedObject.ApplyModifiedProperties();
            return(true);
        }