Show / Hide Table of Contents

Class PrefabUtility

Inheritance
Object
PrefabUtility
Inherited Members
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Namespace: UnityEditor
Assembly: UnityEditor.dll
Syntax
public sealed class PrefabUtility

Fields

| Improve this Doc View Source

prefabInstanceUpdated

Declaration
public static PrefabUtility.PrefabInstanceUpdated prefabInstanceUpdated
Field Value
Type Description
PrefabUtility.PrefabInstanceUpdated

Methods

| Improve this Doc View Source

ApplyAddedComponent(Component, String, InteractionMode)

Declaration
public static void ApplyAddedComponent(Component component, string assetPath, InteractionMode action)
Parameters
Type Name Description
Component component
String assetPath
InteractionMode action
| Improve this Doc View Source

ApplyAddedGameObject(GameObject, String, InteractionMode)

Declaration
public static void ApplyAddedGameObject(GameObject gameObject, string assetPath, InteractionMode action)
Parameters
Type Name Description
GameObject gameObject
String assetPath
InteractionMode action
| Improve this Doc View Source

ApplyObjectOverride(Object, String, InteractionMode)

Declaration
public static void ApplyObjectOverride(Object instanceComponentOrGameObject, string assetPath, InteractionMode action)
Parameters
Type Name Description
Object instanceComponentOrGameObject
String assetPath
InteractionMode action
| Improve this Doc View Source

ApplyPrefabInstance(GameObject, InteractionMode)

Declaration
public static void ApplyPrefabInstance(GameObject instanceRoot, InteractionMode action)
Parameters
Type Name Description
GameObject instanceRoot
InteractionMode action
| Improve this Doc View Source

ApplyPropertyOverride(SerializedProperty, String, InteractionMode)

Declaration
public static void ApplyPropertyOverride(SerializedProperty instanceProperty, string assetPath, InteractionMode action)
Parameters
Type Name Description
SerializedProperty instanceProperty
String assetPath
InteractionMode action
| Improve this Doc View Source

ApplyRemovedComponent(GameObject, Component, InteractionMode)

Declaration
public static void ApplyRemovedComponent(GameObject instanceGameObject, Component assetComponent, InteractionMode action)
Parameters
Type Name Description
GameObject instanceGameObject
Component assetComponent
InteractionMode action

ConnectGameObjectToPrefab(GameObject, GameObject)

Declaration
[Obsolete("Use RevertPrefabInstance. Prefabs instances can no longer be connected to Prefab Assets they are not an instance of to begin with.")]
public static GameObject ConnectGameObjectToPrefab(GameObject go, GameObject sourcePrefab)
Parameters
Type Name Description
GameObject go
GameObject sourcePrefab
Returns
Type Description
GameObject
| Improve this Doc View Source

CreateEmptyPrefab(String)

Declaration
[Obsolete("The concept of creating a completely empty Prefab has been discontinued. You can however use SaveAsPrefabAsset with an empty GameObject.")]
public static Object CreateEmptyPrefab(string path)
Parameters
Type Name Description
String path
Returns
Type Description
Object
| Improve this Doc View Source

CreatePrefab(String, GameObject)

Declaration
[Obsolete("Use SaveAsPrefabAsset instead.")]
public static GameObject CreatePrefab(string path, GameObject go)
Parameters
Type Name Description
String path
GameObject go
Returns
Type Description
GameObject
| Improve this Doc View Source

CreatePrefab(String, GameObject, ReplacePrefabOptions)

Declaration
[Obsolete("Use SaveAsPrefabAsset or SaveAsPrefabAssetAndConnect instead.")]
public static GameObject CreatePrefab(string path, GameObject go, ReplacePrefabOptions options)
Parameters
Type Name Description
String path
GameObject go
ReplacePrefabOptions options
Returns
Type Description
GameObject

DisconnectPrefabInstance(Object)

Declaration
[Obsolete("The concept of disconnecting Prefab instances has been deprecated.")]
public static void DisconnectPrefabInstance(Object targetObject)
Parameters
Type Name Description
Object targetObject

FindPrefabRoot(GameObject)

Declaration
[Obsolete("Use GetOutermostPrefabInstanceRoot if source is a Prefab instance or source.transform.root.gameObject if source is a Prefab Asset object.")]
public static GameObject FindPrefabRoot(GameObject source)
Parameters
Type Name Description
GameObject source
Returns
Type Description
GameObject

FindRootGameObjectWithSameParentPrefab(GameObject)

Declaration
[Obsolete("FindRootGameObjectWithSameParentPrefab is deprecated, please use GetOutermostPrefabInstanceRoot instead.")]
public static GameObject FindRootGameObjectWithSameParentPrefab(GameObject target)
Parameters
Type Name Description
GameObject target
Returns
Type Description
GameObject

FindValidUploadPrefabInstanceRoot(GameObject)

Declaration
[Obsolete("FindValidUploadPrefabInstanceRoot is deprecated, please use GetOutermostPrefabInstanceRoot instead.")]
public static GameObject FindValidUploadPrefabInstanceRoot(GameObject target)
Parameters
Type Name Description
GameObject target
Returns
Type Description
GameObject
| Improve this Doc View Source

GetAddedComponents(GameObject)

Declaration
public static List<AddedComponent> GetAddedComponents(GameObject prefabInstance)
Parameters
Type Name Description
GameObject prefabInstance
Returns
Type Description
List<AddedComponent>
| Improve this Doc View Source

GetAddedGameObjects(GameObject)

Declaration
public static List<AddedGameObject> GetAddedGameObjects(GameObject prefabInstance)
Parameters
Type Name Description
GameObject prefabInstance
Returns
Type Description
List<AddedGameObject>
| Improve this Doc View Source

GetCorrespondingObjectFromOriginalSource<TObject>(TObject)

Declaration
public static TObject GetCorrespondingObjectFromOriginalSource<TObject>(TObject componentOrGameObject)
    where TObject : Object
Parameters
Type Name Description
TObject componentOrGameObject
Returns
Type Description
TObject
Type Parameters
Name Description
TObject
| Improve this Doc View Source

GetCorrespondingObjectFromSource<TObject>(TObject)

Declaration
public static TObject GetCorrespondingObjectFromSource<TObject>(TObject componentOrGameObject)
    where TObject : Object
Parameters
Type Name Description
TObject componentOrGameObject
Returns
Type Description
TObject
Type Parameters
Name Description
TObject
| Improve this Doc View Source

GetCorrespondingObjectFromSourceAtPath<TObject>(TObject, String)

Declaration
public static TObject GetCorrespondingObjectFromSourceAtPath<TObject>(TObject componentOrGameObject, string assetPath)
    where TObject : Object
Parameters
Type Name Description
TObject componentOrGameObject
String assetPath
Returns
Type Description
TObject
Type Parameters
Name Description
TObject
| Improve this Doc View Source

GetIconForGameObject(GameObject)

Declaration
public static Texture2D GetIconForGameObject(GameObject gameObject)
Parameters
Type Name Description
GameObject gameObject
Returns
Type Description
Texture2D

GetNearestPrefabInstanceRoot(Object)

Declaration
public static GameObject GetNearestPrefabInstanceRoot(Object componentOrGameObject)
Parameters
Type Name Description
Object componentOrGameObject
Returns
Type Description
GameObject
| Improve this Doc View Source

GetObjectOverrides(GameObject, Boolean)

Declaration
public static List<ObjectOverride> GetObjectOverrides(GameObject prefabInstance, bool includeDefaultOverrides = false)
Parameters
Type Name Description
GameObject prefabInstance
Boolean includeDefaultOverrides
Returns
Type Description
List<ObjectOverride>

GetOutermostPrefabInstanceRoot(Object)

Declaration
public static GameObject GetOutermostPrefabInstanceRoot(Object componentOrGameObject)
Parameters
Type Name Description
Object componentOrGameObject
Returns
Type Description
GameObject
| Improve this Doc View Source

GetPrefabAssetPathOfNearestInstanceRoot(Object)

Declaration
public static string GetPrefabAssetPathOfNearestInstanceRoot(Object instanceComponentOrGameObject)
Parameters
Type Name Description
Object instanceComponentOrGameObject
Returns
Type Description
String
| Improve this Doc View Source

GetPrefabAssetType(Object)

Declaration
public static PrefabAssetType GetPrefabAssetType(Object componentOrGameObject)
Parameters
Type Name Description
Object componentOrGameObject
Returns
Type Description
PrefabAssetType

GetPrefabInstanceHandle(Object)

Declaration
public static Object GetPrefabInstanceHandle(Object instanceComponentOrGameObject)
Parameters
Type Name Description
Object instanceComponentOrGameObject
Returns
Type Description
Object
| Improve this Doc View Source

GetPrefabInstanceStatus(Object)

Declaration
public static PrefabInstanceStatus GetPrefabInstanceStatus(Object componentOrGameObject)
Parameters
Type Name Description
Object componentOrGameObject
Returns
Type Description
PrefabInstanceStatus

GetPrefabObject(Object)

Declaration
[Obsolete("Use GetPrefabInstanceHandle for Prefab instances. Handles for Prefab Assets has been discontinued.")]
public static Object GetPrefabObject(Object targetObject)
Parameters
Type Name Description
Object targetObject
Returns
Type Description
Object
| Improve this Doc View Source

GetPrefabParent(Object)

Declaration
[Obsolete("Use GetCorrespondingObjectFromSource.")]
public static Object GetPrefabParent(Object obj)
Parameters
Type Name Description
Object obj
Returns
Type Description
Object
| Improve this Doc View Source

GetPrefabType(Object)

Declaration
[Obsolete("Use GetPrefabAssetType and GetPrefabInstanceStatus to get the full picture about Prefab types.")]
public static PrefabType GetPrefabType(Object target)
Parameters
Type Name Description
Object target
Returns
Type Description
PrefabType

GetPropertyModifications(Object)

Declaration
public static PropertyModification[] GetPropertyModifications(Object targetPrefab)
Parameters
Type Name Description
Object targetPrefab
Returns
Type Description
PropertyModification[]
| Improve this Doc View Source

GetRemovedComponents(GameObject)

Declaration
public static List<RemovedComponent> GetRemovedComponents(GameObject prefabInstance)
Parameters
Type Name Description
GameObject prefabInstance
Returns
Type Description
List<RemovedComponent>

HasPrefabInstanceAnyOverrides(GameObject, Boolean)

Declaration
public static bool HasPrefabInstanceAnyOverrides(GameObject instanceRoot, bool includeDefaultOverrides)
Parameters
Type Name Description
GameObject instanceRoot
Boolean includeDefaultOverrides
Returns
Type Description
Boolean

InstantiateAttachedAsset(Object)

Declaration
public static Object InstantiateAttachedAsset(Object targetObject)
Parameters
Type Name Description
Object targetObject
Returns
Type Description
Object
| Improve this Doc View Source

InstantiatePrefab(Object)

Declaration
public static Object InstantiatePrefab(Object assetComponentOrGameObject)
Parameters
Type Name Description
Object assetComponentOrGameObject
Returns
Type Description
Object
| Improve this Doc View Source

InstantiatePrefab(Object, Scene)

Declaration
public static Object InstantiatePrefab(Object assetComponentOrGameObject, Scene destinationScene)
Parameters
Type Name Description
Object assetComponentOrGameObject
Scene destinationScene
Returns
Type Description
Object

IsAddedComponentOverride(Object)

Declaration
public static bool IsAddedComponentOverride(Object component)
Parameters
Type Name Description
Object component
Returns
Type Description
Boolean
| Improve this Doc View Source

IsAddedGameObjectOverride(GameObject)

Declaration
public static bool IsAddedGameObjectOverride(GameObject gameObject)
Parameters
Type Name Description
GameObject gameObject
Returns
Type Description
Boolean
| Improve this Doc View Source

IsAnyPrefabInstanceRoot(GameObject)

Declaration
public static bool IsAnyPrefabInstanceRoot(GameObject gameObject)
Parameters
Type Name Description
GameObject gameObject
Returns
Type Description
Boolean

IsDefaultOverride(PropertyModification)

Declaration
public static bool IsDefaultOverride(PropertyModification modification)
Parameters
Type Name Description
PropertyModification modification
Returns
Type Description
Boolean

IsDisconnectedFromPrefabAsset(Object)

Declaration
public static bool IsDisconnectedFromPrefabAsset(Object componentOrGameObject)
Parameters
Type Name Description
Object componentOrGameObject
Returns
Type Description
Boolean
| Improve this Doc View Source

IsOutermostPrefabInstanceRoot(GameObject)

Declaration
public static bool IsOutermostPrefabInstanceRoot(GameObject gameObject)
Parameters
Type Name Description
GameObject gameObject
Returns
Type Description
Boolean

IsPartOfAnyPrefab(Object)

Declaration
public static bool IsPartOfAnyPrefab(Object componentOrGameObject)
Parameters
Type Name Description
Object componentOrGameObject
Returns
Type Description
Boolean

IsPartOfImmutablePrefab(Object)

Declaration
public static bool IsPartOfImmutablePrefab(Object componentOrGameObject)
Parameters
Type Name Description
Object componentOrGameObject
Returns
Type Description
Boolean

IsPartOfModelPrefab(Object)

Declaration
public static bool IsPartOfModelPrefab(Object componentOrGameObject)
Parameters
Type Name Description
Object componentOrGameObject
Returns
Type Description
Boolean

IsPartOfNonAssetPrefabInstance(Object)

Declaration
public static bool IsPartOfNonAssetPrefabInstance(Object componentOrGameObject)
Parameters
Type Name Description
Object componentOrGameObject
Returns
Type Description
Boolean

IsPartOfPrefabAsset(Object)

Declaration
public static bool IsPartOfPrefabAsset(Object componentOrGameObject)
Parameters
Type Name Description
Object componentOrGameObject
Returns
Type Description
Boolean

IsPartOfPrefabInstance(Object)

Declaration
public static bool IsPartOfPrefabInstance(Object componentOrGameObject)
Parameters
Type Name Description
Object componentOrGameObject
Returns
Type Description
Boolean
| Improve this Doc View Source

IsPartOfPrefabThatCanBeAppliedTo(Object)

Declaration
public static bool IsPartOfPrefabThatCanBeAppliedTo(Object gameObjectOrComponent)
Parameters
Type Name Description
Object gameObjectOrComponent
Returns
Type Description
Boolean

IsPartOfRegularPrefab(Object)

Declaration
public static bool IsPartOfRegularPrefab(Object componentOrGameObject)
Parameters
Type Name Description
Object componentOrGameObject
Returns
Type Description
Boolean

IsPartOfVariantPrefab(Object)

Declaration
public static bool IsPartOfVariantPrefab(Object componentOrGameObject)
Parameters
Type Name Description
Object componentOrGameObject
Returns
Type Description
Boolean

IsPrefabAssetMissing(Object)

Declaration
public static bool IsPrefabAssetMissing(Object instanceComponentOrGameObject)
Parameters
Type Name Description
Object instanceComponentOrGameObject
Returns
Type Description
Boolean
| Improve this Doc View Source

LoadPrefabContents(String)

Declaration
public static GameObject LoadPrefabContents(string assetPath)
Parameters
Type Name Description
String assetPath
Returns
Type Description
GameObject

LoadPrefabContentsIntoPreviewScene(String, Scene)

Declaration
public static void LoadPrefabContentsIntoPreviewScene(string prefabPath, Scene scene)
Parameters
Type Name Description
String prefabPath
Scene scene

MergeAllPrefabInstances(Object)

Declaration
[Obsolete("MergeAllPrefabInstances is deprecated. Prefabs are merged automatically. There is no need to call this method.")]
public static void MergeAllPrefabInstances(Object targetObject)
Parameters
Type Name Description
Object targetObject

ReconnectToLastPrefab(GameObject)

Declaration
[Obsolete("Use RevertPrefabInstance.")]
public static bool ReconnectToLastPrefab(GameObject go)
Parameters
Type Name Description
GameObject go
Returns
Type Description
Boolean

RecordPrefabInstancePropertyModifications(Object)

Declaration
public static void RecordPrefabInstancePropertyModifications(Object targetObject)
Parameters
Type Name Description
Object targetObject
| Improve this Doc View Source

ReplacePrefab(GameObject, Object)

Declaration
[Obsolete("Use SaveAsPrefabAsset with a path instead.")]
public static GameObject ReplacePrefab(GameObject go, Object targetPrefab)
Parameters
Type Name Description
GameObject go
Object targetPrefab
Returns
Type Description
GameObject
| Improve this Doc View Source

ReplacePrefab(GameObject, Object, ReplacePrefabOptions)

Declaration
[Obsolete("Use SaveAsPrefabAsset or SaveAsPrefabAssetAndConnect with a path instead.")]
public static GameObject ReplacePrefab(GameObject go, Object targetPrefab, ReplacePrefabOptions replaceOptions)
Parameters
Type Name Description
GameObject go
Object targetPrefab
ReplacePrefabOptions replaceOptions
Returns
Type Description
GameObject

ResetToPrefabState(Object)

Declaration
[Obsolete("Use RevertObjectOverride.")]
public static bool ResetToPrefabState(Object obj)
Parameters
Type Name Description
Object obj
Returns
Type Description
Boolean
| Improve this Doc View Source

RevertAddedComponent(Component, InteractionMode)

Declaration
public static void RevertAddedComponent(Component component, InteractionMode action)
Parameters
Type Name Description
Component component
InteractionMode action
| Improve this Doc View Source

RevertAddedGameObject(GameObject, InteractionMode)

Declaration
public static void RevertAddedGameObject(GameObject gameObject, InteractionMode action)
Parameters
Type Name Description
GameObject gameObject
InteractionMode action
| Improve this Doc View Source

RevertObjectOverride(Object, InteractionMode)

Declaration
public static void RevertObjectOverride(Object instanceComponentOrGameObject, InteractionMode action)
Parameters
Type Name Description
Object instanceComponentOrGameObject
InteractionMode action

RevertPrefabInstance(GameObject)

Declaration
[Obsolete("Use the overload that takes an InteractionMode parameter.")]
public static bool RevertPrefabInstance(GameObject go)
Parameters
Type Name Description
GameObject go
Returns
Type Description
Boolean
| Improve this Doc View Source

RevertPrefabInstance(GameObject, InteractionMode)

Declaration
public static void RevertPrefabInstance(GameObject instanceRoot, InteractionMode action)
Parameters
Type Name Description
GameObject instanceRoot
InteractionMode action
| Improve this Doc View Source

RevertPropertyOverride(SerializedProperty, InteractionMode)

Declaration
public static void RevertPropertyOverride(SerializedProperty instanceProperty, InteractionMode action)
Parameters
Type Name Description
SerializedProperty instanceProperty
InteractionMode action
| Improve this Doc View Source

RevertRemovedComponent(GameObject, Component, InteractionMode)

Declaration
public static void RevertRemovedComponent(GameObject instanceGameObject, Component assetComponent, InteractionMode action)
Parameters
Type Name Description
GameObject instanceGameObject
Component assetComponent
InteractionMode action
| Improve this Doc View Source

SaveAsPrefabAsset(GameObject, String)

Declaration
public static GameObject SaveAsPrefabAsset(GameObject instanceRoot, string assetPath)
Parameters
Type Name Description
GameObject instanceRoot
String assetPath
Returns
Type Description
GameObject
| Improve this Doc View Source

SaveAsPrefabAsset(GameObject, String, out Boolean)

Declaration
public static GameObject SaveAsPrefabAsset(GameObject instanceRoot, string assetPath, out bool success)
Parameters
Type Name Description
GameObject instanceRoot
String assetPath
Boolean success
Returns
Type Description
GameObject
| Improve this Doc View Source

SaveAsPrefabAssetAndConnect(GameObject, String, InteractionMode)

Declaration
public static GameObject SaveAsPrefabAssetAndConnect(GameObject instanceRoot, string assetPath, InteractionMode action)
Parameters
Type Name Description
GameObject instanceRoot
String assetPath
InteractionMode action
Returns
Type Description
GameObject
| Improve this Doc View Source

SaveAsPrefabAssetAndConnect(GameObject, String, InteractionMode, out Boolean)

Declaration
public static GameObject SaveAsPrefabAssetAndConnect(GameObject instanceRoot, string assetPath, InteractionMode action, out bool success)
Parameters
Type Name Description
GameObject instanceRoot
String assetPath
InteractionMode action
Boolean success
Returns
Type Description
GameObject
| Improve this Doc View Source

SavePrefabAsset(GameObject)

Declaration
public static GameObject SavePrefabAsset(GameObject asset)
Parameters
Type Name Description
GameObject asset
Returns
Type Description
GameObject

SetPropertyModifications(Object, PropertyModification[])

Declaration
public static void SetPropertyModifications(Object targetPrefab, PropertyModification[] modifications)
Parameters
Type Name Description
Object targetPrefab
PropertyModification[] modifications
| Improve this Doc View Source

UnloadPrefabContents(GameObject)

Declaration
public static void UnloadPrefabContents(GameObject contentsRoot)
Parameters
Type Name Description
GameObject contentsRoot
| Improve this Doc View Source

UnpackPrefabInstance(GameObject, PrefabUnpackMode, InteractionMode)

Declaration
public static void UnpackPrefabInstance(GameObject instanceRoot, PrefabUnpackMode unpackMode, InteractionMode action)
Parameters
Type Name Description
GameObject instanceRoot
PrefabUnpackMode unpackMode
InteractionMode action

UnpackPrefabInstanceAndReturnNewOutermostRoots(GameObject, PrefabUnpackMode)

Declaration
public static GameObject[] UnpackPrefabInstanceAndReturnNewOutermostRoots(GameObject instanceRoot, PrefabUnpackMode unpackMode)
Parameters
Type Name Description
GameObject instanceRoot
PrefabUnpackMode unpackMode
Returns
Type Description
GameObject[]

Extension Methods

MustExtensions.MustBeEqual<T>(T, T)
MustExtensions.MustBeEqual<T>(T, T, String)
MustExtensions.MustNotBeEqual<T>(T, T)
MustExtensions.MustNotBeEqual<T>(T, T, String)
MustExtensions.MustBeNull<T>(T)
MustExtensions.MustBeNull<T>(T, String)
MustExtensions.MustNotBeNull<T>(T)
MustExtensions.MustNotBeNull<T>(T, String)
  • Improve this Doc
  • View Source
Back to top Generated by DocFX