Search Unity

"Disconnecting is no longer implemented"

Discussion in 'Prefabs' started by Baste, Apr 5, 2019.

  1. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    4,121
    There's a neat feature in Unity where you can swap the script on a component, and keep all fields with the same name. I often use it to swap a base class for a child class. I tried to do it on a prefab variant, and that doesn't work. Here's it in action:

    Bug.gif

    It looks like everything's fine, but I'm actually attempting to disconnect the prefab. The error message is pretty anonymous:

    upload_2019-4-5_11-39-7.png

    ... That's not very helpful! I also didn't notice it at first, and the prefab mode behaved as if nothing was wrong.

    I understand what's going on, as I remember that in 2018.2 and earlier, swapping the script caused prefabs to become disconnected. So it's obvious that this shouldn't be supported. But unless I spot the error message, it looks like this feature is supported in prefab mode, until I leave and recognize that no changes were applied.

    The error behavior should probably be the same as if you try to delete an object from the base prefab:
    upload_2019-4-5_11-41-46.png
     
    Xarbrough, rentallscript and NeatWolf like this.
  2. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    440
    Hi,

    Thanks, can you please turn it in to a bug report. That makes it easier for us to track.
     
    NeatWolf likes this.
  3. NeatWolf

    NeatWolf

    Joined:
    Sep 27, 2013
    Posts:
    836
    Plus one for this.

    I use it a lot when switching between classes/subclasses, it was a neat way to keep the values of the serialised fields, and I miss it already :)

    I can't reproduce it, tho, using the latest stable version hasn't occurred to me yet.
     
  4. tarahugger

    tarahugger

    Joined:
    Jul 18, 2014
    Posts:
    95
    I'm getting this in 2019.3.0a8 at the moment, fixed a broken script and now it won't save/keep the new reference to the script or any of the values set. It also wont let me open the overrides dropdown for the parent prefab:

    NullReferenceException: Object reference not set to an instance of an object
    UnityEditor.PrefabOverridesTreeView.AddTreeViewItemRecursive (UnityEditor.IMGUI.Controls.TreeViewItem parentItem, UnityEngine.GameObject gameObject, System.Collections.Generic.Dictionary`2[TKey,TValue] prefabOverrideMap, UnityEditor.PrefabOverridesTreeView+IdSequence idSequence) (at <f68ca06da1c243afa30519f1c09ba13a>:0)
     
  5. hashim

    hashim

    Joined:
    Feb 13, 2014
    Posts:
    1
    right click on the gameobject in the hierarchy, select "Open Prefab Asset". now you can add your modified script to the gameobject.
     
  6. Zarkow

    Zarkow

    Joined:
    Jul 27, 2015
    Posts:
    37
    I am getting it in 2018.3.0f2, after purchasing and importing a UI-skin set.
     
  7. choxmi

    choxmi

    Joined:
    Jul 13, 2015
    Posts:
    2
    I'm using 2018.3.6f1 and I fixed this issue by unpacking the prefab. Right click on the prefab and select unpack prefab.