Editor Script and Visual Studio Release Configuration ?

I currently have an editor script that procedurally generates a texture. The majority of the code is math that has no dependencies on UnityEngine, it only uses UnityEngine for the last steps of writing raw data into a texture. When I run this code inside of Unity it takes the same amount of time regardless of what I set for Debug/Release inside of Visual Studio. The time it takes to run is equivalent to the terminal version “Debug” build running with debugging on. Obviously this is much slower than when I create a “Release” build running with debugging off.

Does Unity make use of the selected Solution Configuration from Visual Studio ? What can I do to get my code to run at performance levels equal to a “Release” build version of the code without debugging while inside the editor ?

Does Unity make use of the selected Solution Configuration from Visual Studio ?

No. Not unless you build a separate dll to use within Unity. Unity compile your scripts each time they are saved. Note that running the game (and thus any scripts) through the editor is slower than running a built game. Unity scripts also runs a bit slower than code compiled with Visual Studio when I wrote a few tests some year ago.


I suggest you try build a .net dll of your math code and include it in your project that way, to see if there is any perfomance gains. Please also reply back in a comment when you’ve done so to draw any conclusions wether or not this helped.

I built a .net dll of the math code and linked it into the project. Unfortunately this saw no difference in performance. The code itself is just computing a noise function for a 1024x1024 array. Here are some relative numbers for what is going on.

Running the code inside the editor: 96ms

Building the game and running the code there: 65ms

I get consistent timings regardless of whether I am using the externally built library or I compile the code directly in my project. These are the timings I get outside of unity. Just to clarify the following performance numbers were done in VS with both debug and release builds. The actual code in question is not heavily effected by the the optimize flag so whether the debugger is attached or not is the only real difference.

Running the code in VS with debugging: 74ms

Running the code in VS without debugging: 44ms

I did some further testing and installed a separate mono runtime. By using mono develop I can execute the code on mono or .net. Running on mono independent of unity results in performance numbers that match those I see in unity. I guess it is rather obvious now that I think of it, in unity the code is being executed using mono while in VS and standalone it is being executed using .net. This is the cause of the performance difference. I still find the difference in performance between mono and .net rather surprising since this code is straight forward number crunching.