This is worth thinking about when using Asset Bundles. The Asset Bundle dependency calculation considers stale references, which might create unnecessary dependencies between bundles, loading more than required at runtime. But even then, there are some cases where stale references can cause issues – namely, using pure Asset Bundles. This is not normally an issue during runtime, given that when Unity builds the Player or Addressables, these stale objects and references become cleared. If you recover the Prefab exactly as it was, including the meta file, the reference will be preserved. The same thing would happen if you delete the referenced Bullet Prefab. So long as you have a variable with the same name as the removed one, your changes won’t be lost. You only need to revert the change on your script. Let’s say you mistakenly remove a script property (such as Bullet Prefab) and want to recover it. Finally, re-serialization of assets could be forced via scripting with the AssetDatabase.ForceReserializeAssets API.īut why doesn’t Unity automatically prune stale references in the scenarios listed above? This is primarily due to performance to prevent re-serializing all the assets every time you change one script or base Prefab. Another example centers on placeholder objects of Nested Prefabs that are not removed when the object is deleted from the original Prefab, which again, could be fixed by changing and saving the Prefab. Unless you change and save the Player Prefab again, re-serializing it in the process, the bullet reference will be left in YAML. If you add a Weapon script to the Player Prefab, you’d have to set the Bullet Prefab reference to an existing Prefab, and then remove the Bullet Prefab variable from the Weapon script. There are several scenarios where stale objects and references could be left in YAML one classic case would be removing variables in scripts. In Figure 14, you can see that the “m_TransformParent” property of the PrefabInstance references “fileID: 0.” This means it doesn’t have a father, making it the root object. The base Prefab of a Variant is just a PrefabInstance with a Transform that has no parent, meaning it is the root object of the Variant. As you start referencing more objects in the Nested Prefabs, more of these placeholder objects will be added to the YAML.Ĭonveniently, there’s no difference when it comes to Prefab Variants. Above it, you can see part of another transform whose “m_Father” references this placeholder Transform, making that GameObject a child of the Nested Prefab object. Instead, it has the “m_CorrespondingSourcePrefab” and “m_PrefabInstance” properties filled in a way that references the Nested Prefab Asset and the PrefabInstance object in the file it belongs to. These placeholder objects are marked with the “stripped” tag, which means they are simplified with only the properties needed to act as placeholder objects.įigure 13 similarly shows how we have a Transform marked with the “stripped” tag, which doesn’t have the usual properties of a Transform (like “m_LocalPosition”). Now, you might be wondering, if we don’t have the Nested Prefab objects in our outer Prefab, how do we reference objects in the Nested Prefabs? For such scenarios, Unity creates a “placeholder” object in the Prefab that references the proper object in the Nested Prefab. A real PrefabInstance will typically have more entries in the m_Modifications section. Note that Figure 12 above has been shortened for readability. In Figure 12, we override the X, Y, and Z axes of the original local position of a Transform inside the Nested Prefab, which can be identified via its File ID in the target property. In this case, “100100000” is the File ID of an object created during the import of the Prefab, called Prefab Asset Handle, which won’t exist in the YAML.Īdditionally, “m_Modifications” comprises a set of modifications or “overrides” made to the original Prefab. Now, if you search its File ID in the Nested Prefab Asset, you won’t find it. As you might have noticed, “m_SourcePrefab” is a reference to the Nested Prefab Asset.