• 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 /
This question was closed Jun 30, 2014 at 09:31 PM by Loius for the following reason:

The question is answered, right answer was accepted

avatar image
68
Question by Ehren · Feb 05, 2010 at 11:04 PM · editorprefab

Breaking a prefab connection

Is there a way to break a prefab connection through the editor? If I delete the prefab, the instance of it turns red and seems to want the underlying prefab restored. As it is, the only option seems to be to first delete one of the instance's components (or add one), which causes the editor to warn you that you're losing the connection. Then it's safe to delete the prefab.

Is there a more straightforward way to do this?

Comment
Add comment · Show 4
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 sampenguin · Mar 23, 2011 at 12:44 AM 1
Share

A more explicit and direct way to do this on a single object without toying around with components would be extremely useful as certain plugins (I'm looking at EZ GUI) get really messed up when you duplicate objects in the hierarchy to be used as new prefabs.

avatar image christo1745 · Jun 25, 2012 at 12:10 AM 1
Share

Since this is old, I'll add this here. GameObject>Break Prefab Instance, see my answer below.

avatar image Loius · Jun 30, 2014 at 09:32 PM 0
Share

it is incomprehensible to me that not only are there like five correct answers to this, but we have more co$$anonymous$$g in and none are marked correct yet

y'all be crazy peeps :3

avatar image agasser · Jan 22, 2019 at 02:19 PM 0
Share

I am using Unity 2018.3.0f2 and I can simply right-click on the prefab instance and either click "Unpack Prefab" or "Unpack Prefab Completely". This converts the prefab instance into a regular game object. "Unpack Prefab Completely" is useful if working with nested prefabs. It does all the hassle for you then in one go (unpacking nested prefabs as well). You can delete the prefabs afterwards without issues. HTH, André

7 Replies

  • Sort: 
avatar image
194
Best Answer

Answer by SGage · Mar 01, 2012 at 09:31 PM

Are you looking for "GameObject>Break Prefab Instance" in the menu?

Comment
Add comment · Show 20 · 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 62316e · Jul 30, 2015 at 09:54 AM 6
Share

Does not work as expected in 5.1. After breaking prefab connection you still can Apply changes to original.

avatar image Robotic_Soul 62316e · Mar 25, 2018 at 09:11 AM 0
Share

Still this way in 2017.3.1f1 :(

avatar image bobmoff · Aug 25, 2015 at 02:59 PM 3
Share

Ye, these feature would be greate if it acctually would break it. But the it doesnt. The connection is still there and the apply button is available.

avatar image Trisibo · Jul 23, 2016 at 10:10 PM 5
Share

If you want to completely break the prefab connection (so the prefab buttons are gone), create a new prefab with the object, delete that prefab, and then use the "GameObject -> Break Prefab Instance".

avatar image aaronfranke · Jun 21, 2019 at 09:29 PM 5
Share

Note: For Unity 2019, you need to use the "Unpack Prefab" option ins$$anonymous$$d.

avatar image zurekk · May 14, 2020 at 04:26 PM 2
Share

For Unity 2020, right click the game object and select "Prefab -> Unpack"

Show more comments
avatar image
6

Answer by ricardo_arango · Mar 09, 2012 at 12:23 AM

You can use the PrefabUtility.DisconnectPrefabInstance function to do that:

http://unity3d.com/support/documentation/ScriptReference/PrefabUtility.DisconnectPrefabInstance.html

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
2

Answer by andeeee · Feb 09, 2010 at 05:03 PM

EDIT This answer is obsolete as of Unity 3.5, see accepted answer.

It's not a direct command, but if you modify the object derived from the prefab, you will be asked if you want to break the connection. You could make a small, reversible change, agree to break the prefab connection and then reverse the change. Then, if you delete the prefab, the object is no longer strictly an instance.

Comment
Add comment · Show 4 · 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 Ehren · Feb 09, 2010 at 06:09 PM 0
Share

Thanks, andeeee. I was aware of this option, but was wondering if there were another that was more straightforward. Sounds like this is it.

avatar image yoyo · Jan 27, 2011 at 07:07 PM 0
Share

You could create an editor script for a menu item that adds a component to the instance and then removes it again. This ought to break the prefab connection (haven't tested ...).

avatar image rafefx · May 02, 2011 at 06:00 AM 0
Share

You should be able to make an empty game object a child to break the prefab and then delete it.

avatar image caroparo · May 15, 2011 at 07:52 AM 0
Share

If the GameObject is already in PrefabType.$$anonymous$$issingPrefabInstance state, i.e. text reddened in the Hierarchy view, the only thing one can do to fix it (whiten it again) seems to be: 1. Create a new empty prefab, and replace it with the GameObject. 2. $$anonymous$$odify the GameObject to disconnect it from the linked prefab. 3. $$anonymous$$odify the GameObject back to how it was. 4. Delete the prefab created in step 1.

These can be done in an editor script, but it's just quite wrong isn't it?

avatar image
2

Answer by Rod-Green · Oct 26, 2011 at 09:10 PM

This works - I've tried it. However be warned that it will active gameObjects and their children. So what I did was store the list of active values for the whole hierarchy and then reapply the active values on the clone

 string name = prefabedGO.name;
 Transform parent = prefabedGO.transform.parent;
 prefabedGO.transform.parent = null; // unparent the GO so that world transforms are preserved
 GameObject unprefabedGO = (GameObject)Object.Instantiate(prefabedGO); // clears prefab link
 unprefabedGO.name = prefabedGO.name;
 unprefabedGO.active = prefabedGO.active;
 DestroyImmediate(prefabedGO); // or this could just hide the old one .active = false;
 unprefabedGO.transform.parent = parent;
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 kenlane22 · Oct 11, 2011 at 07:37 PM

Hrmmm. This is still a troublesome thing. Here's my ping to the question and a hopefully a clarification of the pain this brings. And perhaps a start on how to fix it. Imagine this... I made some an awesome prefab (pappy) that has lots of handy and complicated children (kiddos). I then copy a kiddo and paste it as a child to my new collection (newHotness). Now I am secretly screwed (trouble to silently appear later).

So I have:

 pappy   (a prefab)
   kiddo1
   kiddo2
   koddo3

and

 newHotness
   kiddo2
   newKid
  

I create a prefab out of newHotness (cause I'm like that).

Later I'm working on newHotness and I notice that I need to Apply my edits to the newHotness prefab. Sadly, I had kiddo2 selected and it applies my edits to kiddo2 back to the pappy prefab!

Whaaaaaat?!@#?!@?

I finally figure out that the prefab connection (like a sort of plague-like infection) has come along for the ride. kiddo2 never forgets who pappy was. Let's call it the "eternal inappropriate connection." What I desire more than root beer itself is a script that will let me remove the "eternal inappropriate connection" so that kiddo2 can go live his own new life as a member of the newHotness prefab. Anyone know some magic? Ultimately we need a new button next to Select, Revet, Apply, called "Unlink." For now, we make a specialized script:

 [MenuItem("GameObject/Unlink Prefab")]
 static void UnlinkPrefab() 
 {
     foreach( GameObject g in Selection.gameObjects )
     {
         UmmmmmmLikeBreakThatPrefabLinkSomehow( g );
     }
 }

Anybody have a guess for what UmmmmmmLikeBreakThatPrefabLinkSomehow() should be? -Ken =]

Comment
Add comment · Show 2 · 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 kalvinlyle · Mar 08, 2012 at 09:12 PM 0
Share

PrefabUtility.DisconnectPrefabInstance ??

avatar image kenlane22 · Mar 13, 2012 at 08:17 PM 1
Share

Looks like I got what I hoped for for Christmas in Unity 3.5 in the "GameObject -> Break Prefab Instance" menu. Thanks for the code and UnityEditor tips, guys. I'll use both. Lots of goodies deep under the hood in 3.5 for we who keep the pipeline from sucking. -$$anonymous$$en =]

  • 1
  • 2
  • ›

Follow this Question

Answers Answers and Comments

22 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 avatar image avatar image avatar image

Related Questions

adapting replace prefab example 1 Answer

Change angle of camera in prefab preview 4 Answers

Apply only a single value to prefab 1 Answer

PrefabUtility.GetPrefabObject doesn't work! 2 Answers

How to know if something is selected in Hierarchy or in project. 5 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