Search Unity

Built-in components went 'missing' from prefabs at some point (Unity 4.7)

Discussion in 'Editor & General Support' started by AlanGameDev, Feb 28, 2016.

  1. AlanGameDev

    AlanGameDev

    Joined:
    Jun 30, 2012
    Posts:
    437
    Hello there.

    Some built-in components (e.g.: Canvas Scaler and Graphics Raycaster) went 'missing' from my prefabs for no apparent reason. Everything was working properly when that happened. On the inspector they show as "Missing (Mono Script), and when I click the field there I can't select the built-in components that previously were there.

    I would like to somehow restore those components while preserving their serialized data if possible.

    I don't know if it's related, but recently I decided to update to 4.7. That didn't happen immediately when I update and I was able to do some work on 4.7 before that problem.

    Thanks in advance.
     
  2. Shykeas

    Shykeas

    Joined:
    Apr 11, 2015
    Posts:
    145
    Interesting... You can go https://unity3d.com/get-unity/download
    and redownload such. Unselect everything other than Unity/Standard Assets, etc.

    -- Unless these were self-made Mono-Scripts? If they were standard/default then that solution will work.
    If these are self-made you may want to go into the project files and locate them in case their names have changed. Or you possibly deleted them by mistake. Check the trash.

    EDIT: Oops. I missed the first few words apparently. XD
    They ARE built in. To restore BUILT IN scripts/etc. rerun the installer and select which built-in software you'd like to install. That should fix the problem.
     
  3. AlanGameDev

    AlanGameDev

    Joined:
    Jun 30, 2012
    Posts:
    437
    Thank you, but the problem is specific to that project. I'm pretty sure the Unity install is OK so it's not the actual built-in components that got corrupted or something. I guess it's something to do with wrong metadata, it seems to me that Unity is trying to link the wrong components due wrong values in the project files. Perhaps the meta data got corrupted but I don't want to mess with it because I fear the serialized values will be overwritten or something. I really don't want to add the components again and reconfigure them individually.
     
  4. Shykeas

    Shykeas

    Joined:
    Apr 11, 2015
    Posts:
    145
    Ooooh. Hiesty work, I see. Bleh. Yeah. redoing all scenes/a scene with all components is very time consuming and never fun.

    I won't say do it all over.. But I will say that metadata, correct me if I'm incorrect, is linked to SINGLE assets. So, again. all you'd need to do is reinstall/import those same assets. Maybe even delete the old and the metadata files.

    Now, because of this I don't believe you have much of a choice. If you deleted/removed a script in your project file that's linked to a scene object, the object's inspector will say "Missing Monobehaviour" or "Missing Mono-script". This'll happen with those components, too. (Maybe different message) While reimporting that script will not fix that problem. This is due to, I believe, the metadata it's linked to. The metadata is being re-serialized when imported. (And not reimported by right-clicking the project view) So it'll possibly always be lost. :( Sorry, man. I may be wrong on a few parts there but you MIGHT just have to do the scene over again. And if you want those assets back, you can get them from Unity.
     
  5. AlanGameDev

    AlanGameDev

    Joined:
    Jun 30, 2012
    Posts:
    437
    Shykeas thank you. No need to apologize.

    I found no 'easy' way to solve the problem after trying many different approaches, so I've tried messing with the metadata both in the Assets and Library folders with the help of some python scripts I made very quickly... I was trying to get rid of new stuff using the timestamps while keeping everything 'undoable' and magically the thing started working! Yay!

    I've no idea on why or how it fixed the problems, but if anyone have a similar problem the only advice I can do is to try deleting some recent files in the "Library" folder since they do no harm and apparently the metadata in the Assets folder is mostly the serialized components data you don't want to lose. Apparently that's what did the trick for me. The best advice I can give is just backup the whole shebang and mess with the metadata :p.

    I think the problem is due revisions messing up with the Unity data. Unity never worked properly with git for me for example. I have a python script I need to run to reorder metadata in order to make it work properly. But I'm not using git for this project anyway...