LoadPrefabContentsIntoPreviewScene
Loads a Prefab Asset at a given path into a given preview scene.
Read time 1 minuteLast updated 13 days ago
Definition
- Type: Method
- Namespace: UnityEditor
- Assembly: UnityEditor.CoreModule
LoadPrefabContentsIntoPreviewScene(string, Scene)
Loads a Prefab Asset at a given path into a given preview scene.
public static void LoadPrefabContentsIntoPreviewScene(string prefabPath, Scene scene)
Parameters
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. After that you can either reuse your preview scene for other purposes, or close the preview scene with EditorSceneManager.CloseScene.
LoadPrefabContentsIntoPreviewScene(string, Scene, GameObject)
Loads a Prefab Asset at a given path into a given preview scene.
public static void LoadPrefabContentsIntoPreviewScene(string prefabPath, Scene scene, out GameObject rootGameObject)
Parameters
The path of the Prefab Asset to load the contents of.
The Scene to load the contents into.
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. After that you can either reuse your preview scene for other purposes, or close the preview scene with EditorSceneManager.CloseScene.