   Prefabs and prefab-instances
  Hi!My game uses a scene graph of game objects (GO:s).A level-file contains a list of GO:s that sits in the world.Each GO has a list of sub-GO:s that are positioned relative to their parent GO. This creates a hierarchical scene graph.I use the concept of prefab-definitions files. These files contain a small tree of GO:s that makes up a complex thing.Example prefab definition file:{id = 1,type = "prefab-def",pos = { x = 0, y = 0, z = 0 },orientation = 0,},{id = 2,parent = 1,type = "image",bitmap = "spaceship_sheet.png",},{id = 3,parent = 2,type = "collider",},{id = 6,parent = 2,type = "image",bitmap = "tail.png",},{id = 4,parent = 1,type = "speaker",sound = "engine_noise.ogg",loop = true,play = true,},{id = 5,parent = 4,type = "emitter",particlesPerSecond = 20,startSize = 3,endSize = 30,endOpacity = 0,startColor = { red = 1, green = 0.1, blue = 0.1 },}Now I can insert many instances of this prefab into all of my level files.Example level file:{id = 1,type = "image",bitmap = "backdrop_stars.png",}{id = 2,type = "prefab-instance",prefab = "ExamplePrefabDef.prefab"pos = { x = 111, y = 222, z = 333 },}{id = 3,type = "prefab-instance",prefab = "ExamplePrefabDef.prefab"pos = { x = -1000, y = 0, z = 0 },}As you can see I need to be able to override some of the properties of the prefab definition in each instance. When the level is loaded, each "prefab-instance" is replaced with a copy of the prefab-definition, so each prefab-instance is expanded into a small sub-tree of game objects. The reference to the original prefab definition is kept in each prefab-instance.In many cases a prefab-definition is a complete level (but without the player and enemies).My problems:1) In my graphical editor, how do I diff the original prefab definition with the in-game prefab instance so I can save-out only the changed properties? I want to be able to later alter the original prefab definition and have it propagate to all instances!2) How can I override properties of sub-objects of the prefab?3) How can I delete and insert sub-objects in a prefab instance, and still be able to later on improve the original prefab and have those changes propagate to each prefab instance? Example: reuse a level-environment prefab, but edit the instance to make it look battle-scared, add debris etc. How do the program figure-out the changes?I have looked at plenty of game engines and documents but haven't managed to figure this out.Any ideas?/Marcus   
  I now have prefabs working, but a prefab-instance can only override properties in the top-level game object in the prefab definition... And a prefab instance can't yet add or delete sub-object inside the prefab...Still no one that can point me to some source of inspiration? Or give me some clues?/Marcus   ;  Anyone else supporting prefabs in your game? How do _you_ do it?/Marcus   ;  I worked on a game previously that just treated prefabs as a collection of the script commands required to create the object. One benefit to this is that you could add a macro feature to your editor that would record whatever script commands are executed, and play them back for the prefab.It does require a scripting engine, however.   