UnityEditor.PrefabUtility.GetPrefabParent C# (CSharp) Method

GetPrefabParent() private method

private GetPrefabParent ( Object source ) : Object
source Object
return Object
        public static extern Object GetPrefabParent(Object source);
        /// <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);
                     }
                 }
                 using (new EditorGUI.DisabledScope(AnimationMode.InAnimationMode()))
                 {
                     if (prefabType != PrefabType.MissingPrefabInstance)
                     {
                         if (GUILayout.Button("Revert", "MiniButtonMid", new GUILayoutOption[0]))
                         {
                             PrefabUtility.RevertPrefabInstanceWithUndo(go);
                             if (go != null)
                             {
                                 this.CalculatePrefabStatus();
                             }
                             GUIUtility.ExitGUI();
                         }
                         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.ReplacePrefabWithUndo(gameObject);
                                     this.CalculatePrefabStatus();
                                     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::GetPrefabParent