1
\$\begingroup\$

We're using Unity 2017 for a big Indie game. at the moment We have some issues with our development speed:

In order to fix issues and bugs, We used the visual studio and attach the process to Unity and go through the code step by step. every time we change something (even just a line of code) we back to unity and wait for all scripts to recompile which takes up to 1 minutes sometimes. after that, we run the game and go to the place that bug happened which takes us about two minutes.

I was wondering if there was a Best practice for fixing issues and debugging in Unity which brings us speedup on script compiles and also helps us to get to bug location faster.

\$\endgroup\$
3
  • 1
    \$\begingroup\$ Welcome to Unity programming. I don't think there's anything you're doing wrong there. Unity recompiles everything every time. The only possibility is to compile some stuff (that never changes) as a dll and include that so it doesn't have to recompile those parts. \$\endgroup\$
    – Almo
    Commented Jan 21, 2018 at 4:25
  • \$\begingroup\$ That isnt a bad turn around time, in unreal I build editor, server and client(5-45min depending on code changes each), load editor(5mins) then make BP changes, build content for server and client(11-30 mins depending on content changes), push the new server to the server box and fire it up(3-4mins), fire up client and connect then test bug. It could end up taking 30-40 mins to find out the changes I made did nothing. I normally try to make as many changes\fixes as I can to cut down on the turn around. So as you can see a 3min turn around time isn't that bad at all. \$\endgroup\$ Commented Jan 21, 2018 at 6:13
  • 1
    \$\begingroup\$ If I remember correctly in 2017.2 or 2017.3 was mentioned an added feature about arranging parts of the resources in depending hierarchies to speed that process. \$\endgroup\$
    – Nikaas
    Commented Jan 21, 2018 at 6:25

2 Answers 2

2
\$\begingroup\$

Use assembly definitions available in 2017.3.

Unity automatically defines how scripts compile to managed assemblies. Typically, compilation times in the Unity Editor for iterative script changes increase as you add more scripts to the Project.

Use an assembly definition file to define your own managed assemblies based upon scripts inside a folder. To do this, separate Project scripts into multiple assemblies with well-defined dependencies in order to ensure that only required assemblies are rebuilt when making changes in a script. This reduces compilation time. Think of each managed assembly as a single library within the Unity Project. assembly definition example

You can try to separate your code into sections that are as decoupled as possible so that changes to app code will only need to recompile a few pieces at a time. Of course if you have a backend framework that you are debugging it will require recompiling quite a bit on top of it. If that is the case, you may want to create a separate project to reproduce just the issues you are trying to fix.

\$\endgroup\$
2
\$\begingroup\$

You could also consider writing unit tests which can be run externally to your game.

I have been using the built in Unity Test Runner and have saved countless hours fixing bugs by simply writing tests to validate my code.

Test driven development is certainly something I would recommend you implement especially as your project starts to grow in size and your architecture is changing organically.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .