Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to remove Components and Children from Prefabs #101

Open
AdamsLair opened this issue Jun 27, 2014 · 6 comments
Open

Allow to remove Components and Children from Prefabs #101

AdamsLair opened this issue Jun 27, 2014 · 6 comments
Labels
Core Area: Duality runtime or launcher Feature It doesn't exist yet, but I want it Unit Tests Good candidate for adding more tests Usability Related to API and UI usability
Milestone

Comments

@AdamsLair
Copy link
Collaborator

  • Right now, it's impossible to ever remove Components or child GameObjects from a Prefab without having to create a new one and/or updating all of its instances.
  • From a users perspective, this is unusable, and also a ridiculous asymmetry.
  • From a technical side, the reason is that Prefabs allow their instances to carry additional Components and child GameObjects, which in turn means that they're never allowed to remove things, only to add and update.

Come up with a way on how to handle this and allow users to update their Prefabs accordingly.

@AdamsLair
Copy link
Collaborator Author

Solution Idea:

  • Let Prefab instances specify their Component and Child additions explicitly in special ChangeList entries.
    • If an additional Component or Child is not in that list, remove it when applying the Prefab, because this can only happen when it was removed from the Prefab, but not added explicitly to the Prefab instance.
  • As an editor improvement, don't break the Prefablink when removing something relevant from it, but instead warn the user that Prefab instances can never have less contents than their linked Prefabs, and he can either break the link, apply his changes later (to remove it from all) or regard his removal as temporary.
  • Will also need a way to stay backwards-compatible to Prefabs that don't explicitly state their additional stuff.

@AdamsLair AdamsLair added this to the General Improvements milestone Nov 6, 2014
@eriksk
Copy link

eriksk commented Mar 6, 2015

It can be done though. If you remove a component, break the prefab, remove the old prefab in the project view and replace it with the new object sharing the same name it actually works. But kind of a pain though...

@AdamsLair
Copy link
Collaborator Author

It can be done though. If you remove a component, break the prefab, remove the old prefab in the project view and replace it with the new object sharing the same name it actually works. But kind of a pain though...

You don't need to remove the old Prefab though. Just DragDrop the new object onto it and it will be replaced and linked.

The most annoying part of the problem remains though: All your Prefab instances scattered across different Scenes will still retain their additional Component - it won't be removed by applying the new Prefab, because applying Prefabs only ever adds Components and child objects, but never removes them.

@ilexp ilexp added the Unit Tests Good candidate for adding more tests label Oct 27, 2015
@Xinayder
Copy link
Contributor

Why not have the ObjectInspector display what Components and Children the Prefab has, and allow the user to alter them?

@ilexp
Copy link
Member

ilexp commented Jan 30, 2016

Why not have the ObjectInspector display what Components and Children the Prefab has, and allow the user to alter them?

This is a nice addition in itself, but it doesn't solve the fundamental problem of the Prefab system in Duality working in an additive way:

  • Create a Prefab Foo that has a GameObject with a Bar´ and aBar2` Component.
  • Instantiate the Prefab into a GameObject.
  • Now remove Bar2 from the Prefab.
  • Newly instantiated objects will only have Bar, but the previously instantiated one will still keep Bar2, because it will be considered an "add-on" outside the scope of the Prefab.

This core problem needs to be addressed to make Component and child object removal on Prefabs possible.

That said, making Prefabs editable in the object inspector directly is definitely a cool feature. I kind of have this on my list, but it's not a fast-and-easy addition because of various dependencies.

@Keneyr
Copy link

Keneyr commented Oct 27, 2020

I have met the same question here. I tried to remove a component in the prefab. But Destroy() or DestroyImmediate() didn't work. Why addComponent<>() works well . But there's no removeComponent<>() function here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core Area: Duality runtime or launcher Feature It doesn't exist yet, but I want it Unit Tests Good candidate for adding more tests Usability Related to API and UI usability
Development

No branches or pull requests

4 participants