# LoadPrefabContentsIntoPreviewScene

> Loads a Prefab Asset at a given path into a given preview scene.

## Definition

* **Type:** Method
* **Namespace:** [UnityEditor](/engine/6000.5/script-reference/unityeditor.md)
* **Assembly:** UnityEditor.CoreModule

## LoadPrefabContentsIntoPreviewScene(string, Scene)

Loads a Prefab Asset at a given path into a given preview scene.

```csharp
public static void LoadPrefabContentsIntoPreviewScene(string prefabPath, Scene scene)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The path of the Prefab Asset to load the contents of.**** (\[Scene]\(/engine/6000.5/script-reference/unityengine/scenemanagement/scene)): The Scene to load the contents into.

### Remarks

You can use this to get the content of the Prefab and modify it directly instead of going through an instance of the Prefab. This is useful for batch operations.

Once you have modified the Prefab you have to write it back using [PrefabUtility.SaveAsPrefabAsset](/engine/6000.5/script-reference/unityeditor/prefabutility/saveasprefabasset.md). After that you can either reuse your preview scene for other purposes, or close the preview scene with [EditorSceneManager.CloseScene](/engine/6000.5/script-reference/unityeditor/scenemanagement/editorscenemanager/closescene.md).

## LoadPrefabContentsIntoPreviewScene(string, Scene, GameObject)

Loads a Prefab Asset at a given path into a given preview scene.

```csharp
public static void LoadPrefabContentsIntoPreviewScene(string prefabPath, Scene scene, out GameObject rootGameObject)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The path of the Prefab Asset to load the contents of.**** (\[Scene]\(/engine/6000.5/script-reference/unityengine/scenemanagement/scene)): The Scene to load the contents into.**** (\[GameObject]\(/engine/6000.5/script-reference/unityengine/gameobject)): The root GameObject of the loaded Prefab Asset or null if the Prefab couldn't be loaded.

### Remarks

You can use this to get the content of the Prefab and modify it directly instead of going through an instance of the Prefab. This is useful for batch operations.

Once you have modified the Prefab you have to write it back using [PrefabUtility.SaveAsPrefabAsset](/engine/6000.5/script-reference/unityeditor/prefabutility/saveasprefabasset.md). After that you can either reuse your preview scene for other purposes, or close the preview scene with [EditorSceneManager.CloseScene](/engine/6000.5/script-reference/unityeditor/scenemanagement/editorscenemanager/closescene.md).
