Change prefab property in script without initialize and replace?

Even it doable in prefab UI itself. I could not found a way to do it in editor script. The only way I could change prefab property is initialize it and replace it and delete it after even though I just want to change only one property of all prefabs in my project (I want to change a material of all renderer of each children in every prefabs)

Are there anyway we could do that?

Load all your objects using whatever method you want, then loop through them, modify each object, and call EditorUtility.SetDirty on it. Then call AssetDatabase.SaveAssets when you’re done.

1 Like

@Madgvox Thanks you for your answer but today I had update project to 2018.3 was released and it seem there was a new PrefabUtility.SavePrefabAsset function that was really doing the job now

3 Likes

Oh cool, thanks for the info. It’s easy to get behind on API changes if you primarily work in older versions of Unity. :stuck_out_tongue: