Search Unity

Disconnect a prefab 2019

Discussion in 'Prefabs' started by Sandler, Sep 16, 2019.

  1. Sandler

    Sandler

    Joined:
    Nov 6, 2015
    Posts:
    241
    Hi im having some prefabs in my game which are disconnected from their source prefab (they were before updating to 2019)

    With the new prefab workflow i cant disconnect a prefab anymore?
    I wanna work with the disconnected prefab normal inside of the editor. I dont wanna change the prefab object itself, since im shifting elements out and in (its basically a skin overlay system).

    When i unpack the prefab it loses the connection completly, when i unpack completly it does the same.

    How can i disconnect prefabs in 2019?

    Thanks!
     
  2. Sandler

    Sandler

    Joined:
    Nov 6, 2015
    Posts:
    241
    Just read some details:

    "Give some, take some 8 • No more disconnected Prefab instances • No more editing directly in the Project Browser"

    Ok how can i hack into this? Apperently some of my old prefabs are still disconnected.

    Im using the prefab system as a skin overlay, i move elements in and out for positioning. With the new system its way harder to layout elements
     
  3. Sandler

    Sandler

    Joined:
    Nov 6, 2015
    Posts:
    241
    Ill answer it myself:

    you can still overwrite the prefab with some deprecated methods:


    public GameObject prefabSource;
    [InspectorButton("ReplacePrefab")]
    public bool replacePrefab;
    void ReplacePrefab()
    {
    #if UNITY_EDITOR
    PrefabUtility.ReplacePrefab(gameObject, prefabSource, ReplacePrefabOptions.ReplaceNameBased);
    PrefabUtility.ConnectGameObjectToPrefab(gameObject, prefabSource);
    // PrefabUtility.DisconnectPrefabInstance(gameObject);
    #endif
    }