When I add prefabs to the scene, the instances lose their connection to the original prefabs in play mode.
If I instantiate them during runtime with PrefabUtility.InstantiatePrefab(prefab)
instead,
the instances keep their connection to the original prefab.
Since the instances lose their connection to the original prefab, PrefabUtility.RevertObjectOverride
can't be used to reset them to their original state.
Is there a way to add prefabs to the scene while keeping their connection to the original prefab during play mode?
Is there a different (maybe even better) way to reset the prefab instances to their original state?
Prefabs in Unity are an editor only feature. So the "prefab connection" only exists inside the editor. The tools and methods you mentioned are editor only tools that can not be used in a build game.
That said, at runtime (in a build) prefabs are just off-scene instances that only live in memory and can be used as a clone / Instantiate source object. The clone / copy will be placed in the actual scene.
Unity does not really have a built-in concept of saving or restoring the state of a complete object. The closest thing that might work for all serialized primitive fields would be to use Unity's JsonUtility. You can use JsonUtility.ToJson to get a json representation of an object and later use JsonUtility.FromJsonOverwrite to write the serialized values back. However this would need to be done on each object that may belong to a gameobject. So there's still a bit of bookkeeping and boilerplate necessary.
Keep in mind that references can not really be serialized. Unity will serialize the InstanceID which is only valid for the current execution. So that json data can not / should not be stored in a file or be loaded on a different machine.
Since you could actually do any kind of changes to an instance at runtime, which may include the destruction of individual components or adding of additional components, it's usually the best approach to just Destroy the object and instantiate a new one from the original prefab.
If you want to store a reference to the original prefab in the instance itself, be warned that this can not be setup ahead of time because all internal references inside a prefab are "fixed" / adjusted to the instance when it gets instantiated. A common solution is to simply set the reference to the prefab right after you instantiated the prefab. Of course that reference would need to be stored in one of your own MonoBehaviour components. Another solution is to have a ScriptableObject asset as mediator in between. So the instance references the scriptable object which in turn holds the reference to the actual prefab asset.