How to modify several objects via prefab if they are already exist and used in scripts

I have several objects which are already involved in scripts. And now I need to change them. I don’t change each one separately, I can use the prefab. So, I created an empty object, then moved it to a folder, created a prefab, added 1 object there and edited it as needed. All is well, but now how do I apply these changes to other objects? When I pull out a prefab, add what can no longer be there, a message appears (see pic1).

For clarity. There are several objects, I need to change all of them, but they are already present and used in scripts. In order not to change each one separately, how exactly to work with the prefab? I looked at the documentation again, but apparently I do not understand something203745-scr2023-01-10-154929.jpg

Instead of changing them through prefab, as this will change the prefab itself and will probably revert after exiting the game, make the prefab have a custom tag (If you don’t know how to do this, I can help), and do

foreach (GameObject g in GameObject.FindGameObjectsWithTag("your tag"))
{
    g.doYourEdits;
}

Thanks to kaosermail on answers.unity.com for some of this.
Having said that, if you just want to change it in the inspector, just do the “Open Prefab” and change it.
If you found this helpful, please “Accept Answer”!

  • if you want to change the objects at run time (while the game is running) then you cannot change the prefab. you must get a reference to all the objects and change each one.

  • if you meant changing the object in edit mode, then you need to create a prefab from the gameobject in the hierarchy which is identical in all the objects. once you create the prefab you need to modify all the objects to include that prefab. only than, changes to that prefab will apply in the objects.