Quantcast
Channel: Answers for "Wait times when developing"
Viewing all articles
Browse latest Browse all 6

Answer by Mackam

$
0
0
I've successfully reduced the time it takes to test my network game from **21.5 sec** to **4 sec**! Sit down for a moment and I'll explain how I did it. **+ Compression** The main fault turned out to be the compression of assets. Disabling compression shaved off so much time that I wonder why it's even enabled by default (disk space is not much of a problem today while someone's time is always invaluable). 1) Edit > Preferences... > General 2) Uncheck "Compress Assets on Import" 3) Edit > Preferences... > GI Cache 4) Uncheck "Cache compression" 5) Press the Clean Cache button 6) Assets > Reimport All Don't know how much time is saved from disabling cache compression for the GI Cache but I bet there's some time to gain there as well. **+ Two Unity Editors** Another huge improvement was running the game in two instances of Unity instead of building a stand-alone exe-file to act as the client or server. This also spares you from the 5 sec long Unity logo (that I didn't even include in my measured 21.5 sec). 1) Edit > Preferences... > External Tools 2) Uncheck "Editor Attaching" 3) Create a new, blank dummy Unity project in a new folder 4) Close Unity and navigate to the dummy project's folder 5) Delete the "Assets" and "ProjectSettings" subfolders 6) Open cmd.exe as Administrator 7) cd "DummyProjectFolderPath" 8) mklink /D "DummyProjectFolderPath\Assets" "RealProjectFolderPath\Assets" 9) mklink /D "DummyProjectFolderPath\ProjectSettings" "RealProjectFolderPath\ProjectSettings" 10) Create a batch file ("MyProjectName.bat") with two lines: start "" "C:\Program Files\Unity\Editor\Unity.exe" -projectPath "DummyProjectFolderPath" start "" "C:\Program Files\Unity\Editor\Unity.exe" -projectPath "RealProjectFolderPath" 11) Start working on your game by running the batch file from now on Two instances of Unity will be opened, they both share the exact same Assets on disk (scripts etc) and will have the exact same settings (layer names etc) as long as you save the scene before tabbing to the other instance of Unity. The "mklink" program comes with Windows and is used here to create symbolic links to the two key directories of your real Unity project. Unity might notice that you are using symbolic links in which case it'll warn you that you have to know what you are doing, which we do (it doesn't actually affect anything). Since you edit the same script files in two instances of Unity I don't know how well "editor attaching" would work. I'm disabling that feature just to be sure everything works, it's fine for me since I don't use it. If you need it you could try keeping it checked, maybe it works? **+ Anti-Virus interference** Unity can do its job a little bit faster if it is left alone by other processes. Exclude your real project and dummy project folders from being scanned by your anti-virus software and tell it to leave Unity.exe and MonoDevelop.exe alone as well. If you just use the built-in Microsoft Security Essentials like me here's what you do: 1) Settings > Excluded files and locations 2) Browse for the dummy project folder, press Add 3) Browse for the real project folder, press Add 4) Save changes 5) Settings > Excluded processes 6) Browse for "C:\Program Files\Unity\Editor\Unity.exe", press Add 7) Browse for "C:\Program Files\Unity\MonoDevelop\bin\MonoDevelop.exe", press Add 8) Save changes **+ Standard Assets** When you change a script Unity will recompile ALL your scripts. Except those that are put in Standard Assets (unless you change a script in there, then Unity will still recompile all scripts). So, make a folder named "Standard Assets" if there isn't one already. Alternatively you can name it "Plugins" or "Pro Standard Assets" instead but "Standard Assets" is nice since it will be sorted next to your "Scripts" folder if you have one named as such. Just make sure it is placed in the root of your project's Assets folder. Drag-and-drop all scripts that you are finished with into this special "Standard Assets" folder. Or those that you know you won't update often. The only downside to this is that scripts in Standard Assets can't use scripts outside of that folder (can use other scripts inside that folder though, and outside scripts can use everything inside the Standard Assets folder). If you get errors when dragging a script into the Standard Assets folder just keep dragging more scripts into it until the errors go away. If you need to make a change to a script in the Standard Assets folder don't be afraid to do it like normal, all that will happen is that Unity has to recompile all scripts in your project. If you know you need to work a lot on a script in the Standard Assets folder you can drag it outside of the folder again to reduce compile time. If you get errors just keep dragging more scripts out of Standard Assets (those mentioned in the error messages) until you don't have any errors left. Example: You have 100 scripts, 80 are inside Standard Assets. You make a change to 1 of the 20 scripts outside Standard Assets - Unity will recompile 20 scripts. You make a change to 1 of the 80 scripts inside Standard Assets - Unity will recompile all 100 scripts. **+ Conclusion** Now Unity is fun to work with again! Launching a test of my game is over 5 times faster. In my opinion the developers should do everything they can to make all of these steps I just listed needless for anyone to do. In this day and age you should have a optimized workflow out of the box with no extra work needed, nobody likes wasting their time waiting around. *Edit: I got some major error once about things being out of sync ("Timestamps (52) and assets (50) maps out of sync"). This was fixed by closing both instances of Unity and then deleting the "Library" folder in both project maps. These are rebuilt automatically by Unity upon start and the error should be gone.* *Edit 2: Sometimes one of the still-playing Unity Editors crashes after stopping playing the game in the other Unity Editor. This forces me to close the other one as well and run the batch file to open both instances of Unity again. I don't know why it crashes and have posted a question about it over here:* http://answers.unity3d.com/questions/968218/unity-srashing-efter-losing-connection-to-other-un.html

Viewing all articles
Browse latest Browse all 6

Latest Images

Trending Articles





Latest Images