Search Unity

Missing scripts in saved prefab

Discussion in 'Prefabs' started by Zoulz, Aug 28, 2019.

  1. Zoulz

    Zoulz

    Joined:
    Mar 14, 2014
    Posts:
    13
    So I instantiate a new game object and nest a bunch of prefab objects to it. I then add a component to each of them. When I use the SaveAsPrefabAsset in PrefabUtility it saves the game object and it's children as a new asset. Great, that's exactly what I want. But the components I added are now reported as missing inside the prefab. I'm doing all of this by script. Is there something I need to do for the instantiated components to "stick" to their respective game objects before I can save?
     
  2. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    639
    That sounds really strange.

    Can you file a bug report and share a small project that reproduces the issue
     
  3. Zoulz

    Zoulz

    Joined:
    Mar 14, 2014
    Posts:
    13
    It seems like the cause of the problem was that I had multiple monobehaviours in the same file. After putting them into separate files they are no longer missing inside the prefab. :)
     
  4. SteenLund

    SteenLund

    Unity Technologies

    Joined:
    Jan 20, 2011
    Posts:
    639
    Ah, yes that is actually not allowed. I do believe the script compilation warns about this