Hey, I’m creating an in-game console for my game. My goal is to have an attribute that I can put on top of functions, and then the console system will gather those functions to create the commands that users can input at runtime.
Now, a solution to this is to gather these attributes at runtime at startup, and then build a list there. However, reflection is slow and it won’t scale too well with the amount of commands in the game, and just getting quicker load times, even by a bit can easily be worth this effort, if it’s possible.
So. Is there a way to generate the different commands at compile time? Writing them to a file is also a bit slow to read, so it would be great if I could somehow have that array in memory. Maybe there’s a pre-compile process where I can create a .cs file with the hard-coded array? Although I’d prefer to just not have any assets at all in regards to this, so maybe there could also be some code generation, which I have no idea how to do.