My game starts out with a massive worldbuilding step that takes a very long time. Most of the heavy work involves a C# implementation of Box2D. It feels like there must be some overhead running this code in Unity when it doesn’t really need to (it doesn’t use much of Unity’s API). I was wondering if it would be worth implementing some big chunks of my code in a separate DLL? Would it being unmanaged C++ help much at all? I’m sure it would help at least some, but it’s a big task and I’d like to know if I could expect orders-of-magnitude improvement.
Are there other tricks I can do?
Ideally I’d like the CPU to be firing on all cylinders. Is there any way I can max out my CPU during this step, or is that more of an OS specific thing?
Unity is only using a single core, so if your world building algorithms can benefit from parallelism your best bet is probably threading.
Have you profiled the code and determined where the performance issues are? Identify those first before deciding how to optimize. Sometimes an algorithm change is what’s called for instead of a new compiler.
And can you do your calculations in the background while showing an opening video? Or a progress screen that shows game hints? If we’re talking about a minute or so, that’s a viable option as well. Give the player something interesting to look at while they’re waiting.
And is this something that happens every time the game starts? Or just when starting a new game? If the former, wouldn’t you just do that the first time and save the results?