Project Raygine #12 - thoughts on prefabs
The last days, I did a large number of refactorings to clean up the codebase - like I described in the previous post. It's not all done yet, but I have now established patterns where to move bindings and documentation to. When I encounter cases now, I can quickly fix them one after another.
Another thing I did was adding materials and some mesh primitive drawing with material bindings:
I also added a new behavior yesterday to my test project to test input handling:
These things worked fine and as expected, but I stumbled over lot's of issues when I tried adding prefab functionality; I really haven't thought much in general about runtime related scene and object manipulation. I got something working this morning through some hacks and efforts:
The projectiles in this test are spawned through the space ship behavior, cloning a referenced projectile scene entity. I discovered this way a lot of gaps in my current thought model on how this should be handled - I simply haven't really thought about it at all. One particular problem is: When cloning an existing structure, which values are copied and which ones are referenced? I believe that Unity is solving this through serialization. This was my first attempt as well, but it's tricky, because my current serialization system relies on storing the stuff in object tables of asset files. Since runtime assets aren't going into assets, this isn't going to work. I got the current system running through deep cloning the referenced prefab and having a logic to decide if a value is to be copied or referenced. I got it sort of working, but I think it has a lot of issues and I'm not sure if it's the right way to go. I'll have to think about this more.