UnityEditor.GameObjectInspector.DoPrefabButtons C# (CSharp) Method

DoPrefabButtons() private method

private DoPrefabButtons ( PrefabType prefabType, GameObject go ) : void
prefabType PrefabType
go UnityEngine.GameObject
return void
        private void DoPrefabButtons(PrefabType prefabType, GameObject go)
        {
            if (this.m_HasInstance)
            {
                using (new EditorGUI.DisabledScope(EditorApplication.isPlayingOrWillChangePlaymode))
                {
                    EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
                    GUIContent content = (base.targets.Length <= 1) ? s_Styles.goTypeLabel[(int) prefabType] : s_Styles.goTypeLabelMultiple;
                    if (content != null)
                    {
                        GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(24f + s_Styles.tagFieldWidth) };
                        EditorGUILayout.BeginHorizontal(options);
                        GUILayout.FlexibleSpace();
                        if (((prefabType == PrefabType.DisconnectedModelPrefabInstance) || (prefabType == PrefabType.MissingPrefabInstance)) || (prefabType == PrefabType.DisconnectedPrefabInstance))
                        {
                            GUI.contentColor = GUI.skin.GetStyle("CN StatusWarn").normal.textColor;
                            GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.ExpandWidth(false) };
                            GUILayout.Label(content, EditorStyles.whiteLabel, optionArray2);
                            GUI.contentColor = Color.white;
                        }
                        else
                        {
                            GUILayoutOption[] optionArray3 = new GUILayoutOption[] { GUILayout.ExpandWidth(false) };
                            GUILayout.Label(content, optionArray3);
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                    if (base.targets.Length > 1)
                    {
                        GUILayout.Label("Instance Management Disabled", s_Styles.instanceManagementInfo, new GUILayoutOption[0]);
                    }
                    else
                    {
                        if ((prefabType != PrefabType.MissingPrefabInstance) && GUILayout.Button("Select", "MiniButtonLeft", new GUILayoutOption[0]))
                        {
                            Selection.activeObject = PrefabUtility.GetPrefabParent(base.target);
                            EditorGUIUtility.PingObject(Selection.activeObject);
                        }
                        if (((prefabType == PrefabType.DisconnectedModelPrefabInstance) || (prefabType == PrefabType.DisconnectedPrefabInstance)) && GUILayout.Button("Revert", "MiniButtonMid", new GUILayoutOption[0]))
                        {
                            List<Object> hierarchy = new List<Object>();
                            this.GetObjectListFromHierarchy(hierarchy, go);
                            Undo.RegisterFullObjectHierarchyUndo(go, "Revert to prefab");
                            PrefabUtility.ReconnectToLastPrefab(go);
                            Undo.RegisterCreatedObjectUndo(PrefabUtility.GetPrefabObject(go), "Revert to prefab");
                            PrefabUtility.RevertPrefabInstance(go);
                            this.CalculatePrefabStatus();
                            List<Object> list2 = new List<Object>();
                            this.GetObjectListFromHierarchy(list2, go);
                            this.RegisterNewComponents(list2, hierarchy);
                        }
                        using (new EditorGUI.DisabledScope(AnimationMode.InAnimationMode()))
                        {
                            if (((prefabType == PrefabType.ModelPrefabInstance) || (prefabType == PrefabType.PrefabInstance)) && GUILayout.Button("Revert", "MiniButtonMid", new GUILayoutOption[0]))
                            {
                                List<Object> list3 = new List<Object>();
                                this.GetObjectListFromHierarchy(list3, go);
                                Undo.RegisterFullObjectHierarchyUndo(go, "Revert Prefab Instance");
                                PrefabUtility.RevertPrefabInstance(go);
                                this.CalculatePrefabStatus();
                                List<Object> list4 = new List<Object>();
                                this.GetObjectListFromHierarchy(list4, go);
                                this.RegisterNewComponents(list4, list3);
                            }
                            if ((prefabType == PrefabType.PrefabInstance) || (prefabType == PrefabType.DisconnectedPrefabInstance))
                            {
                                GameObject source = PrefabUtility.FindValidUploadPrefabInstanceRoot(go);
                                GUI.enabled = (source != null) && !AnimationMode.InAnimationMode();
                                if (GUILayout.Button("Apply", "MiniButtonRight", new GUILayoutOption[0]))
                                {
                                    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();
                                        EditorSceneManager.MarkSceneDirty(source.scene);
                                        GUIUtility.ExitGUI();
                                    }
                                }
                            }
                        }
                        if (((prefabType == PrefabType.DisconnectedModelPrefabInstance) || (prefabType == PrefabType.ModelPrefabInstance)) && GUILayout.Button("Open", "MiniButtonRight", new GUILayoutOption[0]))
                        {
                            AssetDatabase.OpenAsset(PrefabUtility.GetPrefabParent(base.target));
                            GUIUtility.ExitGUI();
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }
        }