Sunday, November 29, 2015

unity - How to make prefabs independent?


I'm working on a Unity's Project and I want to modify a prefab, more precisely I want to change the texture of a prefab. The problem is that my modification is applied also to other prefabs. I read on the documentation how each of the buttons labeled Select, Revert and Apply works, and what I understood is that the modification should update only the selected prefab.


Here is the Prefabs' Manual which I read.


What am I missing?


PS: I'm not the author of the project, I have to apply some modifications only.



Answer



It's more likely that you're modifying the material the prefab is using, and other prefabs using that material are being affected. While you are correct that what you're doing shouldn't modify the other prefabs, those prefabs still share a reference to the same material. When modifying a material, it affects all objects and prefabs that reference that material.



You should make a copy of the material and reference the copy from the prefab you want to modify.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...