Documentation

Unity Engine


User Manual

Script Reference

Unity Engine


ConnectGameObjectToPrefab(GameObject, GameObject)

Connects the source Prefab to the game object.
Read time 1 minuteLast updated 4 days ago

Definition

  • Type: Method
  • Namespace: UnityEditor
  • Assembly: UnityEditor
Warning
Deprecated. Use ConvertToPrefabInstance() or ReplacePrefabAssetOfPrefabInstance() which has settings for better control.
public static GameObject ConnectGameObjectToPrefab(GameObject go, GameObject sourcePrefab)

Parameters

The disconnected GameObject that you want to reconnect.

sourcePrefab

The source Prefab to connect to the GameObject.

Returns

Type

Description

GameObject

Remarks

This method allows you to reconnect a GameObject to its source Prefab, when it has become disconnected. Prior to 2018.3 it was possible for Prefab instances to become disconnected from their source Prefab. This method fixes that connection. From 2018.3 onwards, Prefabs cannot become disconnected, so this method exists only to correct problems that may exist in projects created in earlier versions of Unity.