1 - Create MonoBehaviour Script
2 - Go in your code editor, open that script and create a public List variable and add some elements inside the List in runtime. Maybe use Update() method so it is up to you achieve the result of updating the list…
3 - Create prefab from that MonoBehaviour Script
4 - While in edit mode, add(drag) the Prefab into scene and add some elements to the dragged prefab’s list by manually using the inspector. (if the list you created is private you must serialize first or make it public)(What i mean by adding elements, if it is integer, add something inside the list inside the prefab in the scene. Not to the asset itself or literally you can manipulate the asset itself before dragging into the scene too because still, i dont know how the bug occurs)
5 - (Most importantly)Play the game and after the list gets updated in runtime, check the list in Prefab Asset itself AND the dragged Scene Prefab GameObject.
6 - (Most importantly 2)Go into Edit mode back. Check the list in Prefab Asset itself AND the dragged Scene Prefab GameObject AGAIN. Now both or one of them will get overriden.
It happens sometimes. I request some investigation because even i give you a sample project, it does not mean you will see the bug…
This almost always happens simply because you dragged the prefab into a public field that subsequently modifies the prefab, rather than dragging the in-scene instance in.
Uh in point 4, i actually said “Add Prefab into scene and add some elements by manually (In prefab, into the list and inside the scene as well)” which means i did dragged the prefab in scene which real asset shouldn’t get overidden in play mode. I wont report as a bug until someone encounters the same issue with me.
Correct… unless you also dragged this same prefab into the slot of ANOTHER script somewhere else that is changing it.
Perhaps you’re seeing a new bug, I’m simply pointing out that this sounds like a bug I’ve seen ten billion times in the last 12 years of using Unity, that’s all.
And if you ever do find a way to reliably repro, definitely file the bug. Unity does fix this stuff.
I finally figured it out why it happens. It happens if you just assign prefab’s referenced value to instantiated one:
...
var instantiatedPrefab = Instantiate(prefabReference);
instantiatedPrefab.vectorList = prefabReference.vectorList; // List is reference type
instantiatedPrefab.vectorList[0].x = 1;
Debug.Log(prefabReference.vectorList[0]);
...
So it updates the asset itself even if you are in the play mode. I dont know if it could be considered as bug… And yeah i should have been said “I am instantiating a prefab” while presenting the ‘bug’ sorry i thought it wasnt important at all.