How to avoid this Unity Prefab Modifications behavior?

Viewed 486

Desc:

There is a component with list data:

public class TestPrefab : MonoBehaviour
{
    public List<string> DataList;
}

Then I create a prefab with this component like this: enter image description here

Then I drag the prefab into scene, modify the component data like this ("Data1"=>"Data1_Modified") (I wont apply changes because I just wanna keep it as a prefab instance, which has some changes from the origin prefab): enter image description here

Then back to the prefab stage, delete the first data: enter image description here

Then the prefab instance in the scene comes to: enter image description here

How does it happen?

unity save this modification like this: enter image description here
so unity just change the first data in the list to "Data1_Modified", rather than change "Data1" to "Data1_Modified".

Question:

Is there any elegant method to avoid this unpredicted behavior?

1 Answers

you should apply this edits on prefabs so after you finish in inspector menu press on overrides then apply all
enter image description here


prefabs are prefabricated objects so to update them from Scene window you need to tell editor to apply your changes on prefabs.

Related