- Home /
Unresponsive Unity Editor
Hey there!
Recently, since 4.2 I think, my Unity Editor has been behaving really weirdly. I created a test scene for our next project, and spread grass all over a newly created terrain.
The thing is, when I set the detail distance to 250, which is a correct minimum considering my system specs (i7 3770K, HD 7870, 8 GB RAM, W7 64 bits) and the amount of stuff in the scene, the Editor starts to be really unresponsive. It's impossible to work, since every action or command is proccesed with lots of lag.
Trying and testing, I stumble unto two curious things:
Considering the Editor in Scene view, as mentioned before, is very unresponsive, I went to the QualitySettings menu to try and look for a solution. There, before I even tweaked anything, I noticed that I could navigate the Scene without any lag or trouble! Zooming, moving, etc. Switching between the QualitySettings menu and the Scene tab, the performance difference became really apparent (and yes, I did try every quality setting available, with no result in my Scene).
The issue is far stranger, because I found out that the Editor is actually usable if I stick to make every action just under 2 seconds from the previous. I mean, the problem, apparently, is that my Unity Editor "disconnects", "goes idle" after 2 seconds have passed since the previous action. So (and I have tried it extensively, and it works) I could work with it if I could just make all actions at blazing fast speed, within that 2 second window between one another.
But I guess, I would just play Starcraft professionally if I could do so.
Thanks!
What's your base terrain pixel error? $$anonymous$$ake sure its set to something around 5. Setting it to 1 will lag any computer. The only other thing I can think of is too many grass instances, but I doubt this is problem unless you're up in the multi-terrain, 500,000+ area. Have you tried using the profiler on the editor?
Thanks for responding! Pixel error is 5, absolutely. $$anonymous$$aybe there are too many grass instances, how should I check that? But I wonder, if that's the case, why I can certainly use the Editor at its full potential at such extremely odd circumstances.
Didn't check the profiler. Looks like I got to, to rule out any possible motive.
Thanks!
Answer by MicroGSD · Aug 08, 2013 at 12:26 AM
Try adding this to your assets: http://detail.microgsd.com/2013/08/these-functions-will-tell-you-total.html . It'll tell you how many grass / details you have. If you're in the millions range you will probably experience slowdowns, which would be the answer to why the editor is clunky.
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
public class GSDEditor : ScriptableObject{
//Get all terrains:
[MenuItem( "GSD/Get grass count" )]
public static void GetGrassCount(){
Object[] tTerrains = GameObject.FindObjectsOfType(typeof(Terrain));
//For each terrain:
foreach(Terrain tTerrain in tTerrains){
GetGrassCount_Helper(tTerrain);
}
}
private static void GetGrassCount_Helper(Terrain t){
// Get all of layer zero.
int numDetails = t.terrainData.detailPrototypes.Length;
int grasscount = 0;
for(int i=0;i < numDetails;i++){
//Get the detail layer:
int[,] map = t.terrainData.GetDetailLayer(0,0,t.terrainData.detailWidth, t.terrainData.detailHeight, i);
//For each pixel in the detail map:
for (int y=0;y < t.terrainData.detailHeight;y++){
for (int x=0;x < t.terrainData.detailWidth;x++){
grasscount+=map[x,y];
}
}
}
Debug.Log("Grass #: " + grasscount);
}
}
Symptoms of millions of grass:
http://forum.unity3d.com/threads/90923-Terrain-CullAllTerrains-causes-stutter
http://forum.unity3d.com/threads/174761-In-Game-drawing-on-terrain-feels-slow
http://forum.unity3d.com/threads/177758-Moving-Unity-Terrain-causes-severe-lag
http://forum.unity3d.com/threads/117431-Terrain-performance-issues
You can get around it by temporarily setting the detail resolution and detail per patch very low, and then re-upping it during playtime or right before playtime. There's probably other solutions.
Edit: It seems you can improve the performance a bit if you set the detail resolution to the same resolution as the terrain. However you increase draw calls doing this.
Answer by JGPicatoste · Aug 08, 2013 at 11:38 AM
Sorry for not replying earlier. I'm gonna try and do all your solutions, I might be over millions of grass instances, yeh. Will reply with anything, positive or negative.
Edit:
1.640.000 is the actual amount. Are we to rule out any other possible reason, and assume it's just a matter of grass instances?
Thank you!
I think it's purely based on the number of grass instances as looking into the profiler, the function calls increase as more grass patches are added. The only way to mitigate this currently that I know of, is to keep the detail resolution the same as the heightmap resolution, while keeping the detail per patch low.
I think the only real alternative is creating your own grass system for the terrain.
You might try posting about this problem on the unity forums and seeing if you get an answer there, as it really is just an editor issue.
Hm, what really grinds my gears is that I've tried it on another computer (actually, a less powerful one) and it works like a charm all the way.
It shouldn't be connected to the number of grass instances if that's the case.
Thank you, will keep on looking onto this!
Really? That's interesting. I get the slow downs running on 8 cores @ 4.9 GHZ. I'll keep looking into it too, I'll post back here if I find anything.
Yeh haha, it's driving me nuts! I'm gonna try and install an earlier version of Unity, gonna see if that solves anything.
Edit: It solved nothing. I've prepared a video showing how it's sluggish in the Scene $$anonymous$$ode, but in the QualitySettings menu works perfectly in whatever quality.
$$anonymous$$ight upload it later.
Your answer
Follow this Question
Related Questions
Strange Hierarchy Lag 1 Answer
Lag in Inspector 0 Answers
Unity is reacting really slow, and it opens a second instance of the Editor 2 Answers
Unity does not open or start properly 0 Answers