Search Unity

Error: The root GameObject of the opened prefab... moved out of Prefab Stage...

Discussion in 'Prefabs' started by andyz, Jun 19, 2019.

  1. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,269
    After updgrading a project to 2018.4.2 & new prefabs. Many of the generated prefabs do not opene and show "Exiting Prefab Mode" dialog with "Error: The root GameObject of the opened Prefab has been moved out of the Prefab Stage scene by a script."

    what is this about?!

    Edit: old NGUI components are just not compatible with the prefab system - I need an NGUI update...
    Fixed in newer NGUI - update in your current Unity, then update Unity version
     
    Last edited: Dec 3, 2019
    RoboDrone, epernigo and bgm0 like this.
  2. flogram

    flogram

    Joined:
    Nov 27, 2016
    Posts:
    1
    I'm getting the same error, preventing me from editing the prefabs. Does anyone know how to fix this?
     
  3. runevision

    runevision

    Joined:
    Nov 28, 2007
    Posts:
    1,892
    The answer is right in the first post you replied to.
     
  4. klemikaze

    klemikaze

    Joined:
    Oct 2, 2023
    Posts:
    1
    For anyone interested: I wanted to change prefabs hierarchy if Application.IsEditor in Awake method. Since it depended on other objects, the Awake method probably failed when opening in Prefab Editor so long story short this helped me:

    Before:


    Code (CSharp):
    1.  
    2.     private void Awake()
    3.     {
    4.  
    5.         if (Application.isEditor)
    6.         {
    7.                 world = GameObject.Find("World").GetComponent<WorldBehaviour>();
    8.                 var unitWrapper = GameObject.Find("Units");
    9.                 transform.parent = unitWrapper.transform;
    10.             }
    11.  
    12.     }
    13.  
    After:

    Code (CSharp):
    1.  
    2.     private void Awake()
    3.     {
    4.  
    5.         if (Application.isEditor)
    6.         {
    7.             if (PrefabStageUtility.GetCurrentPrefabStage() == null)
    8.             {
    9.                 world = GameObject.Find("World").GetComponent<WorldBehaviour>();
    10.                 var unitWrapper = GameObject.Find("Units");
    11.                 transform.parent = unitWrapper.transform;
    12.             }
    13.  
    14.         }
    15.     }
    16.