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

(Case 1108062) Cannot remove "Missing Script" Component from Prefab

Discussion in 'Prefabs' started by Peter77, Dec 9, 2018.

  1. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    4,788
    2018.3 is unable to remove a Component from a Prefab, where the Component Script is missing. Trying to remove the missing Component outputs the following error to the Debug Console:

    Reproduce
    1) Open attached user project
    2) Select "Assets/Item_AmmoBox.prefab"
    3) Click "Open Prefab" in Inspector
    4) Right-click "(Script)" and select "Remove Component"
    5) Observe it displays "Saving failed" error dialog, click OK
    6) Leave prefab edit mode by clicking the "<" button in the Hiearchy
    7) Click "Save" in the "Prefab Has Been Modified" dialog

    Actual
    Unity displays "Saving failed" and the Components with missing Scripts can't be removed.

    Expected
    Being able to remove Components whose Scripts are missing.
     
    LeonhardP likes this.
  2. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    1,998
  3. dontdiedevelop

    dontdiedevelop

    Joined:
    Sep 18, 2018
    Posts:
    68
    OlegPavlov likes this.
  4. APSchmidt

    APSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    3,513
    There is a workaround:
    1. drop the prefab in the Hierarchy view,
    2. in the inspector for the prefab that you just dropped on the scene, remove the components you need to be removed,
    3. override the changes in the prefab.
    It's not perfect but it will allow you to wait until the problem has been fixed.
     
    muhamad1987 likes this.
  5. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,656
    Still not fixed in Unity 2019.1?

    I upgraded a project and I'm unable to remove a missing script from a prefab. The workaround suggested above here was what I attempted first as that was the most intuitive way, but I'm not allowed to override the prefab because it tells me I'm not allowed to apply the changes when I have an invalid script (which I'm trying to remove).

    This is ridiculous. What is this "feature" attempting to safe guard me from doing? I'm attempting to fix my prefab, but it's actively preventing me from doing this.

    I had to delete my prefab and all instances of it and recreate it from scratch.
     
  6. APSchmidt

    APSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    3,513
    I tried in a brand new project:
    1. dragged a sphere on the scene,
    2. created a script and added it to the sphere,
    3. made the sphere a prefab,
    4. placed several instances of the sphere in the hierarchy view,
    5. deleted the script, in order to create the "missing script",
    6. opened the prefab,
    7. removed the script,
    8. the script was removed from all the existing objects on the scene as well.
    I remade the experience but this time, after placing several instances of the prefab in the hierarchy view:
    1. deleted the script, in order to create the "missing script",
    2. selected all the instances of the prefab in the hierarchy view,
    3. removed the missing script,
    4. as happened to you, I wasn't able to override the prefab, but...
    5. the missing script went away by itself after I lost the focus on Unity, because I was writing this post.
    It seems that the prefab fixed itself after all.

    Anyway, it seems that the right way is removing the missing script in the prefab instead of doing it in the instances of the object.
     
  7. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,656
    No idea. Didn't work for me. The missing script was part of the old post processing stack which is now built-in to HDRP so I deleted the package after I upgraded the project, but I was unable to remove the post processing script from my camera.

    Will keep an eye out if happens again.

    But HDRP doesn't seem to interact well with the new prefab system in general. The camera and light data components that are automatically added to cameras and lights are added multiple times and show up as overrides for the prefab etc.
     
  8. barbelot

    barbelot

    Joined:
    Jul 18, 2017
    Posts:
    15
    I have a similar problem where adding a HD Camera to a prefab always create a missing script which then cannot be removed.

    To reproduce :
    1. Create a camera in your scene (with HDRP this automatically add the HD Additional Data script to it).
    2. Create a prefab from this camera.

    The prefab will be created with a missing script that cannot be removed. The camera in the scene will also now have two HD Additional Data scripts on it with one greyed out and marked as removed.

    upload_2019-5-2_14-50-5.png
     
  9. Doomlaser

    Doomlaser

    Joined:
    Dec 9, 2013
    Posts:
    8
    what the hell... I'm on 2019.1.6f1. I have a prefab with a missing script apparently. It tells me I can't override, enter Prefab mode. I find and remove the script -- on a Camera -- and it can't save, I get this same error as the OP:

    "You are trying to replace or create a Prefab from the instance 'portal camera' that references a missing script. This is not allowed.
    Please change the script or remove it from the GameObject"

    Rermoving it from the GameObject throws this error! I'm trapped! This sucks!
     
  10. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    522
    @Doomlaser

    Can you please file a bug report with a small project that reproduces the issue
     
  11. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    4,788
    I'm still able to reproduce this issue in the currently latest 2018 LTS build.

    I submitted the following bug-report with Unity 2018.4.3f1:
    (Case 1167814) 2018.4: Cannot remove missing Script Component from Prefab

     
  12. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    4,788
  13. B1QQ

    B1QQ

    Joined:
    Aug 16, 2018
    Posts:
    8
    not fixed in 2019.1.10f1
     
  14. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    4,788
    Have you found the "Resolution note" from the bug-report?
    https://issuetracker.unity3d.com/issues/cannot-remove-missing-script-component-from-prefab
     
  15. Rayeloy

    Rayeloy

    Joined:
    Feb 12, 2017
    Posts:
    28
    not fixed in 2019.2.12f1
     
  16. Sam_Space

    Sam_Space

    Joined:
    Jun 28, 2019
    Posts:
    3

    Tried this method on 2018.4.3 and it worked out. However I noticed the error really came from an object I was trying to child to the parent prefab object. The object had a script that was declared missing. I tossed the script component and that worked out.
     
  17. JacobSchwitzer

    JacobSchwitzer

    Joined:
    Jul 19, 2018
    Posts:
    1
    Hey, my team and I had this error for the last week and this forum helped us find a solution that also works. We created a new prefab from the previous one, removed the missing scripts, reattached them, replaced the old prefab with this new one in scene, and then deleted the old one. I hope this helps anyone else who stumbles onto this!
     
unityunity