UnityEditor.PrefabUtility.GetPrefabObject C# (CSharp) Method

GetPrefabObject() private method

private GetPrefabObject ( Object targetObject ) : Object
targetObject Object
return Object
        public static extern Object GetPrefabObject(Object targetObject);
        /// <summary>

Usage Example

 private void DoPrefabButtons(PrefabType prefabType, GameObject go)
 {
     if (this.m_HasInstance)
     {
         using (new EditorGUI.DisabledScope(EditorApplication.isPlayingOrWillChangePlaymode))
         {
             EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
             GUIContent gUIContent = (base.targets.Length <= 1) ? GameObjectInspector.s_Styles.goTypeLabel[(int)prefabType] : GameObjectInspector.s_Styles.goTypeLabelMultiple;
             if (gUIContent != null)
             {
                 EditorGUILayout.BeginHorizontal(new GUILayoutOption[]
                 {
                     GUILayout.Width(24f + GameObjectInspector.s_Styles.tagFieldWidth)
                 });
                 GUILayout.FlexibleSpace();
                 if (prefabType == PrefabType.DisconnectedModelPrefabInstance || prefabType == PrefabType.MissingPrefabInstance || prefabType == PrefabType.DisconnectedPrefabInstance)
                 {
                     GUI.contentColor = GUI.skin.GetStyle("CN StatusWarn").normal.textColor;
                     GUILayout.Label(gUIContent, EditorStyles.whiteLabel, new GUILayoutOption[]
                     {
                         GUILayout.ExpandWidth(false)
                     });
                     GUI.contentColor = Color.white;
                 }
                 else
                 {
                     GUILayout.Label(gUIContent, new GUILayoutOption[]
                     {
                         GUILayout.ExpandWidth(false)
                     });
                 }
                 EditorGUILayout.EndHorizontal();
             }
             if (base.targets.Length > 1)
             {
                 GUILayout.Label("Instance Management Disabled", GameObjectInspector.s_Styles.instanceManagementInfo, new GUILayoutOption[0]);
             }
             else
             {
                 if (prefabType != PrefabType.MissingPrefabInstance)
                 {
                     if (GUILayout.Button("Select", "MiniButtonLeft", new GUILayoutOption[0]))
                     {
                         Selection.activeObject = PrefabUtility.GetPrefabParent(base.target);
                         EditorGUIUtility.PingObject(Selection.activeObject);
                     }
                 }
                 if (prefabType == PrefabType.DisconnectedModelPrefabInstance || prefabType == PrefabType.DisconnectedPrefabInstance)
                 {
                     if (GUILayout.Button("Revert", "MiniButtonMid", new GUILayoutOption[0]))
                     {
                         List <UnityEngine.Object> hierarchy = new List <UnityEngine.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 <UnityEngine.Object> list = new List <UnityEngine.Object>();
                         this.GetObjectListFromHierarchy(list, go);
                         this.RegisterNewComponents(list, hierarchy);
                     }
                 }
                 using (new EditorGUI.DisabledScope(AnimationMode.InAnimationMode()))
                 {
                     if (prefabType == PrefabType.ModelPrefabInstance || prefabType == PrefabType.PrefabInstance)
                     {
                         if (GUILayout.Button("Revert", "MiniButtonMid", new GUILayoutOption[0]))
                         {
                             List <UnityEngine.Object> hierarchy2 = new List <UnityEngine.Object>();
                             this.GetObjectListFromHierarchy(hierarchy2, go);
                             Undo.RegisterFullObjectHierarchyUndo(go, "Revert Prefab Instance");
                             PrefabUtility.RevertPrefabInstance(go);
                             this.CalculatePrefabStatus();
                             List <UnityEngine.Object> list2 = new List <UnityEngine.Object>();
                             this.GetObjectListFromHierarchy(list2, go);
                             this.RegisterNewComponents(list2, hierarchy2);
                         }
                     }
                     if (prefabType == PrefabType.PrefabInstance || prefabType == PrefabType.DisconnectedPrefabInstance)
                     {
                         GameObject gameObject = PrefabUtility.FindValidUploadPrefabInstanceRoot(go);
                         GUI.enabled = (gameObject != null && !AnimationMode.InAnimationMode());
                         if (GUILayout.Button("Apply", "MiniButtonRight", new GUILayoutOption[0]))
                         {
                             UnityEngine.Object prefabParent = PrefabUtility.GetPrefabParent(gameObject);
                             string             assetPath    = AssetDatabase.GetAssetPath(prefabParent);
                             bool flag = Provider.PromptAndCheckoutIfNeeded(new string[]
                             {
                                 assetPath
                             }, "The version control requires you to check out the prefab before applying changes.");
                             if (flag)
                             {
                                 PrefabUtility.ReplacePrefab(gameObject, prefabParent, ReplacePrefabOptions.ConnectToPrefab);
                                 this.CalculatePrefabStatus();
                                 EditorSceneManager.MarkSceneDirty(gameObject.scene);
                                 GUIUtility.ExitGUI();
                             }
                         }
                     }
                 }
                 if (prefabType == PrefabType.DisconnectedModelPrefabInstance || prefabType == PrefabType.ModelPrefabInstance)
                 {
                     if (GUILayout.Button("Open", "MiniButtonRight", new GUILayoutOption[0]))
                     {
                         AssetDatabase.OpenAsset(PrefabUtility.GetPrefabParent(base.target));
                         GUIUtility.ExitGUI();
                     }
                 }
             }
             EditorGUILayout.EndHorizontal();
         }
     }
 }
All Usage Examples Of UnityEditor.PrefabUtility::GetPrefabObject