- Home /
Why would editor script be slow on first compilation?
An editor script I've written to create sound effects runs really slowly when I first boot up Unity. Forcing Unity to recompile my script by either running the game or changing any arbitrary line in the script makes it run significantly faster. A 2 second long effect takes about 250ms to build at first but the same effect only takes about 25ms to build after forcing the recompilation.
Does anyone have any idea why this would happen or what if anything I can do to fix it?
I can't even begin to think of what could be wrong. Could you post the script? And maybe even the kinds of changes you are making to recompile?
The portion of the script that takes any amount of time is here: http://pastebin.com/Abvyui51 I can't really post everything related to it as it's just too much.
Literally just adding int x = 12;
to the bottom of the Process function to make it recompile makes it 10x faster. Then I can delete that line and it remains faster until the next time I close and reopen the Unity Editor.
Dang, I have no idea, hah. It doesn't make any sense to me. Have you tried removing the editor preprocessor portion? I've never included it in unity so that could be a reason why it's slowing down compilation.