Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by Uninity · Nov 23, 2012 at 01:27 PM · gameobjectprefab

How to add a prefab back to a gameobject that is missing one?

I opened my scene in Unity and my character model has dissapeared. However, I still have the prefab in my project, can i some how re-attach this back to the GameObject?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

5 Replies

· Add your reply
  • Sort: 
avatar image
8

Answer by TomYeti · Aug 27, 2019 at 08:03 PM

I've solved this same issue today, and I want to offer a little bit more thorough and updated response.

My issue was similar, I had prefab instances somehow tied to the wrong prefab, which i deleted. The new prefabs in my project were identical fbx files I had imported.

Assuming you have "Force Text" enabled for Asset Serialization, you can do this:

  1. Open your scene with broken prefab instances in your IDE of choice. For me, that's VS code. It should be a YAML file.

  2. Back in Unity, find the name of the prefab that is broken. Mine was "FTC_DZ_ALL_Terrain". Make sure these names are unique, if they aren't, rename a duplicate that isn't missing.

  3. Back in your IDE, use the "Find" tool to find that name. Only one object should have it.

  4. You will find a line that says "value: FTC_DZ_ALL_Terrain". The parent of that line should read "-target: {fileID: [some numbers here], guid: [guid goes here]}" and possibly other things. You want to know the guid. Copy that guid. For instance "d09aaea6fade35141905fd9dd33b5c51"

  5. Open up find and replace. paste that guid in the find category.

  6. Now, navigate to the prefab in your project you want to replace this object with. Open the ".meta" file associated with that prefab. ie, if your prafab is named "MyPrefab.prefab", open the file titled "MyPrefab.prefab.meta"

  7. Find the line that says "guid" near the top and copy the guid.

  8. Back in your scene file, paste that guid in the "Replace" field of your find and replace.

  9. Press "Replace all" to replace all occurances with that

  10. To check if it was successful, save your scene file and open it in Unity. Hit "Reload" if prompted.

  11. Viola!

I'm not sure if it handles nested prefabs perfectly, you may need to replace more than just the parent GUID. But so long as you're replacing the right guids, it should all work out.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by Alex_May · Sep 23, 2015 at 05:33 PM

Try this replace objects with prefab script. It saved my bacon the other day.

https://bitbucket.org/thisishydra/hydracommon/src/master/Scripts/Editor/Windows/ReplaceGameObjects.cs?at=master

Comment
Add comment · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image ErikH2000 · Jun 13, 2020 at 09:50 PM 0
Share

I appreciate the link, and it will work for some cases. I'll add for the next person that the shortco$$anonymous$$g is that any property overrides will be lost. So in my case, I use ProBuilder objects that store a different mesh as an override of the property. The code in the script above doesn't have a way to copy this kind of data.

avatar image briggs · Sep 18, 2020 at 12:56 PM 0
Share

I am a noob when it comes to unity. How do I run the missing prefab script?

avatar image ErikH2000 · Sep 11, 2021 at 07:56 PM 0
Share

@briggs, you might have to do a bit more code changes beyond this, but using the linked code as a starting point: 1. Change HydraEditorWindow to EditorWindow (from UnityEditor namespace). 2. To open the editor window, call code like GetWindow<ReplaceGameObjects>();

If that doesn't work well, consider that you don't need the editor window stuff at all. You just need to call the Replace() function passing in the right params. You can make a simply MonoBehavior-based class with some properties to do that. Just understand that the code must run in edit mode and not play mode.

avatar image
1

Answer by colakovicrajko · Aug 24, 2020 at 09:48 PM

For me this issue was solved by going to Assets (at the top toolbar), then clicking Reimport All.

It happened after using Git to switch from my Ubuntu computer to my macbook.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image eovento · Mar 15, 2021 at 01:05 PM 0
Share

Anyone, before trying the first answer (which in my (and most!) case would be more troublesome than rebuilding the whole project from scratch), please do yourself a favor and try this solution first, and then send @colakovicrajko a virtual hug.

It took a click and a few seconds for all my missing prefabs to get fixed. Thank you very much! :)

avatar image
0

Answer by IT_Criminal · Nov 23, 2012 at 02:21 PM

1) in the hierarchy view click on the bugged game object

2) in the inspector view click on "Revert" to reset the game object to prefab settings

3) tell me if it worked

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image enderandpeter · Sep 23, 2015 at 04:47 PM 0
Share

I recently added many game objects to organize the hierarchy of scenes, but after others checked out my changes, they saw missing prefabs for many game objects whose prefab I had swapped. Everything is fine in my original working directory, but I see the missing data when I checkout the project anew. When I select a $$anonymous$$issing Prefab object, there are no "Apply, Select, Revert" buttons in the Inspector.

avatar image
0

Answer by oigetinthevan · Sep 11, 2021 at 07:21 PM

This may not solve this particular case of missing prefab, but for me, I had a game object in a prefab that was supposedly missing after pulling from my repo.

Opening the original prefab and toggling the enable/ disable button on a component in the "missing object" fixed all instances of this problem for me.

Hope this helps.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

19 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

A node in a childnode? 1 Answer

Is it possible to edit the sub-sub-GameObjects of a prefab in the assets window? 1 Answer

How does Unity retain UnityEngine.Object references? 2 Answers

Prefab (Project Folder) to a GameObject (on the Scene) 2 Answers

Sporadic Failure of GetComponentInChildren 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges