Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

"Disconnecting is no longer implemented"

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

  1. Baste


    Jan 24, 2013
    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:


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


    ... 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:
  2. SteenLund


    Unity Technologies

    Jan 20, 2011

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


    Sep 27, 2013
    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


    Jul 18, 2014
    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


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


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


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


    Sep 27, 2013
    Unity 2019.
    Unity 2019.2.8f1: still getting that error.

    in debug mode I swapped one script on a prefab instance in the Hierarchy tab with a child class of that script (this usually causes no data loss since most of the fields are the same).

    First, I renamed the script (added an underscore inbetween - yes, I know, I usually don't use underscore in class names)
    The prefab broke like this:

    And the infamous "disconnecting is no longer implemented" error popped up

    So I created a child class of Puzzle_Socket, calling it Puzzle_Gear.

    I enabled Debug mode to see if my data was already there but:

    Which is weird, since I have no compile errors!

    Is it because I'm using generics?

    So, I replaced the script with the child class and, as usual, all data is still there:

    You can even see that there are a few fields marked in bold as dirty or "overriden from the prefab value"

    Notice the "+" icon, like I was trying to add a new script to the prefab, which is not true.

    Of course, since I've got many prefabs, the next step was to Apply the changes to all the instances of the prefab, but:

    The script is in no way invalid.

    Is this a new issue?

    I fear I lost all of my data used by the base class, and my last commit to the repo was hours ago :/

    Do you have any clue?
    Is script swapping being deprecated in some way? That was insanely useful to me - the only alternative I can think of is creating "migration" scripts using deep copying.

    And yet I can't figure out a single reason which makes a perfectly running script from being considered invalid.

    I already restarted Unity, but didn't change a thing.

    Any clue?


    Looks like I needed to open the prefab, swap the base class (for some reason marked as invalid even by reimporting it or changing it to force a recompile) with the child class, and exit Prefab mode.

    Doing it on an instance causes the above issue: you can't apply a change even if you deleted the offending script in the instance, because it has no effect on the prefab, which still contains the invalid script.
    In this case, the invalid script should have been marked for removal. Instead it just disappears from the inspector, but it only disappears from the instance, creating some confusion. [ISSUE]

    This was an instance from which I deleted the "invalid script".
    The script got hidden, and replacing in the instance the base class with the child class caused the inspector to assume it was a new component.

    As I correctly replaced the script in Prefab mode, I went back to check that instance and, surprise!
    The script has always been there, but now is correctly marked as removed from the prefab instance.
    Last edited: Oct 5, 2019