Prefab Overrides Considered Harmful

Punny title notwithstanding, I have decided that “prefab overrides” in Unity are more trouble than they are worth. The idea of course is to allow parametric variation of instances within a scene, but in practice I just seem to wind up with accidental breakage where overrides get lost because of a change to the prefab itself.

UPDATE: Essentially every issue I’ve had with prefabs has been fixed in more recent versions of Unity, rendering prefab overrides far more useful in practice.

I recently had a case where I made a build of a game and shipped it out and someone notified me that a particular game element was unavailable in most game modes. Turns out I had accidentally applied what ought to have been an override to the base prefab. Any scenes that had not overriden it now got the inappropriate value. D'oh. In other cases, I’ve had overrides simply get lost due to changes – particularly linkages to other objects that exist in the scene.

Basically, as near as I can tell, the only time it’s really “safe” to use prefab overrides is when the prefab is more or less “set in stone”. However, when is a prefab ever really “done”? I’ve had way too many cases where I wanted to go back and change a prefab late in the development cycle.

In the worst case, the breakage that happens here could easily create a paralysis that discourages developers from changing prefabs that they know are used in a lot of places! The end result of course being a more brittle and change-resistent development process.

I don’t really know whether the root of the issue is in how Unity handles prefab overrides and bugs/unintended consequences there – or if it’s something more fundamental to the idea of prefab overrides. Either way though, I’m on the lookout for techniques or approaches that can give similar flexibility without the risks.

unity 319 words, est. time: 63 seconds.

« Unity's Reflective/Diffuse is Broken. Here's the Fix. Ideas for managing the lifecycle of Unity objects gracefully »


Copyright © 2018 - Jon Frisby - Powered by Octopress