I’m looking for the best approach to auto-generate a handful of code files. These will each contain a different Component type, based on JSON data that’s been provided by the user (one of our developers).
Ideally, the user’s experience would go like this:
- The user populates a JSON file with data that will be used to produce all the needed Component types.
- The user selects a menu item from inside the Unity editor.
- That menu item causes several new Component files to be created, based on the JSON data.
- Unity imports the new files and recompiles.
This process would only need to happen rarely.
Most of the code-gen I’ve done in the past has used a simple, home-brew approach in which I build strings to represent the new files, and then write those strings to disc. That’s worked ‘ok’, and it would work ‘ok’ again, here.
But I’ve always wanted to level up my code-gen knowledge. I’ve researched different methods, but it can be difficult to understand which ones are intended for which use cases.
I’m wondering how you all would approach this problem in your own work. Are there better - go-to methods you would use to auto-generate files like this?
Thank you sincerely for any advice.