
[ad_1]
The trick to that is that Unity’s prefabs aren’t strictly a part of its part system (although they use options of parts). They’re a part of its serialization system.
Try setting Unity’s asset serialization mode to “Force Text” and study a scene file in a textual content editor to see this in motion.
The serialized model of a recreation object contained in the scene references that object’s prefab, in addition to itemizing any parameters which were overridden from the prefab.
When you open a scene, exit play mode, or make a change to a prefab, Unity’s deserializer populates every of these situations by first making a clone of the prefab’s information (like your prototype instance), then overwriting every parameter that the occasion being deserialized overrides, as described in its serialized file.
The inspector can learn this serialized information (or an equal in-memory construction) to know which fields to attract within the overridden fashion or inherited fashion. When you alter an inherited discipline, it may be added as one other override to file when serializing the occasion. When you click on “revert”, Unity clears all override notes related to the occasion.
Nowhere on this course of do the parts themselves have any idea of inheritance or overriding of their fields. That layer could be utilized utterly exterior to the part system, used at runtime solely when an object in a scene (or the brand new nested prefabs) must be deserialized. (Though this inheritance may presumably get “baked out” at construct time and keep away from any runtime inheritance of part parameters in any respect)
[ad_2]