In the worst case, such properties might reference assets that are then pulled into the final build, taking up space on the storage device and in memory – but never used.
Overrides are now flagged as unused for:
Null target objects
Unknown Property Paths (which are not subject to scripted FormerlySerializedAsAttribute usage)
Removed components
Removed GameObjects
Changed array dimensions (e.g., materials array)
3 Ways to remove the Overrides:
Hierarchy Window > Scene Context Menu > Prefab > Remove
Hierarchy Window > Prefab/Prefabs Context Menu > Prefab > Remove
I can’t find a way to do this for a bunch of prefab variants at once. I have a lot of prefab variants which have tons of unused overrides that are bloating the asset file. There should be a way to remove all unused overrides on all those prefab variants without having to open each one of them and manually click on the remove unused overrides button. Even from script, PrefabUtility doesn’t expose any method for manipulating unused overrides as they are all internal.
When selecting one or more Prefab instances in the Hierarchy and opening the Overrides drop-down, the Editor now shows whether there are unused Overrides. You can then remove them from the scene using the new Unused Overrides drop-down.
Yeah that doesn’t work for prefab variant assets. Prefab variants are like prefab instances but I have to open each prefab variant individually to remove unused overrides. I wish I could remove unused overrides on prefab variant assets by just selecting them in the project instead of having to open them. That way I could select many of them and remove unused overrides in one click.
Is there something in the Unity API that we can use to remove unused references as a part of our build pipeline via script? I’d love to do this before building.