Search Unity

Opening Prefab Mode failed: Could not detect a Prefab root after loading 'Assets/Prefabs/

Discussion in 'Prefabs' started by TerraCo, Nov 30, 2018.

  1. TerraCo

    TerraCo

    Joined:
    Jun 8, 2013
    Posts:
    26
    Upgraded from b11 to b12 and slowly, one by one, my prefabs no longer open in Prefab Mode. I have to drag them into the scene, modify, save, then delete.

    upload_2018-11-30_14-27-29.png
     
  2. TerraCo

    TerraCo

    Joined:
    Jun 8, 2013
    Posts:
    26
    Resaving the prefabs gave them all a new ID which broke references in every Scriptable Object
     
  3. ProtonOne

    ProtonOne

    Joined:
    Mar 8, 2008
    Posts:
    406
    I got this error after upgrading b11 to b12 too. Right click on the prefab and Reimport to fix
     
    ZingZangGames, Rumbod, kadted and 2 others like this.
  4. TerraCo

    TerraCo

    Joined:
    Jun 8, 2013
    Posts:
    26
    Ah jeez! I wish I knew that a few hours before recreating prefabs and references. Thanks!
     
  5. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    217
    A bug report with one of the Prefabs that show this problem would be appreciated. Please post case number here.
     
  6. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,609
    LeonhardP likes this.
  7. ProtonOne

    ProtonOne

    Joined:
    Mar 8, 2008
    Posts:
    406
    I have tried to reproduce the problem, but it won't happen anymore.

    My version control shows that when it did happen, nothing changed on the prefabs themselves when reimporting, so the problem would likely be in the library folder (which I don't put into version control).

    It is entirely possible just just closing and re-opening the project could have fixed the problem too. I've verified that all my prefabs work now, even ones that I did not reimport before.

    I've done various tests upgrading a smaller sample project with a bunch of prefabs from b11 to b12 but the problem will not happen again...

    If I can find a way to reproduce it again I'll submit a bug report.
     
  8. sethwklein

    sethwklein

    Joined:
    Oct 24, 2014
    Posts:
    8
    I have this problem consistently with Unity 2018.3.0b12 on Mac OS X. I reproduce as follows:

    * Open a prefab
    * Press Command+B to build for Android
    * Attempt to open the same the prefab as before
    * Observe error message instead of expected prefab opening

    Opening a different prefab will work. Restarting Unity will unbreak the broken prefab, as will Reimporting the broken prefab using the context menu.

    I'd use the bug reporter, but I can't change attachments there because the attachment file picker doesn't respond to clicks on any files or folders. I'd attach a prefab here, but I'm not allowed to attach .meta or .prefab files. Since it seems to be related to modifying and building, not the particular prefab, perhaps you'll manage without the files anyway.

    I'll recheck this thread in case there's more information I can provide.
     
  9. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    217
    Do you have any special build scripts that changes prefab assets when building?
    You can also create a small repro project, zip the project and send it directly to me (mads@unity3d.com)
     
  10. sethwklein

    sethwklein

    Joined:
    Oct 24, 2014
    Posts:
    8
    Here's a repro that doesn't rely on a large and proprietary project:

    * Create new project
    * Add a game object called Prefab to SampleScene, drag it to the Assets folder to make a prefab, and delete it from the scene
    * Create a new C# script containing a public member variable of type GameObject
    * Add another game object to SampleScene, add the script to it, and drag the prefab to the script's member variable
    * Open the prefab
    * Build the project. This will close the prefab
    * Attempt to open the prefab
    * Observe unexpected error: Opening Prefab Mode failed: Could not detect a Prefab root after loading 'Assets/Prefab.prefab'.

    * Set the script's member variable to None
    * Open the prefab (you'll have to reimport it or reopen Unity)
    * Build
    * Attempt to open the prefab
    * Observe the opened prefab as expected

    Still haven't tested on anything except Mac OS X and Unity 2018.3.0b12, but have now tested with both Android and standalone build targets.

    If you still can't repro, I'll do it again and mail you the project, but I think you should have no trouble now.
     
    LeonhardP and ProtonOne like this.
  11. ProtonOne

    ProtonOne

    Joined:
    Mar 8, 2008
    Posts:
    406
    Good catch @sethwklein

    I was able to reproduce this in 2018.3 b12 using your steps. Also confirmed that this bug does not happen in 2018.3 b11.

    I've submitted a bug report with my small test project with the following info:

    1. What happened
    Double clicking to edit a prefab results in an error:
    Opening Prefab Mode failed: Could not detect a Prefab root after loading 'Assets/Prefabs/Prefab_Empty.prefab'.

    This bug report is for the following forum thread:
    https://forum.unity.com/threads/ope...fab-root-after-loading-assets-prefabs.590611/


    2. How we can reproduce it using the example you attached
    1. Open the project in 2018.3 b12
    2. Double click on each prefab in the Prefabs folder to confirm they all work
    3. Close the prefab view (exit prefab editing)
    4. Build the project
    5. Double click on each prefab in the Prefabs folder again

    Expected Result
    Should still be able to edit the prefabs

    Actual Result
    Opening Prefab Mode failed: Could not detect a Prefab root after loading 'Assets/Prefabs/Prefab_Empty.prefab'.

    I'll post the bug # once it is available.
    EDIT: Case 1107035
     
    Last edited: Dec 5, 2018
    sethwklein and LeonhardP like this.
  12. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    217
    sethwklein likes this.
  13. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
  14. Mads-Nyholm

    Mads-Nyholm

    Unity Technologies

    Joined:
    Aug 19, 2013
    Posts:
    217
  15. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    The fix will be included in the next release.
     
    geranim0 likes this.