Hey,
I’m working on a 2D terrain Engine. If “paint mode” is enabled, I use Gizmos.DrawGUITexture in a OnDrawGizmos funtction to show the brush position in the editor scene view. Of course it’s based on the mouse position. However, due to the nature of the scene renderer this guitexture only gets updated when a mouse button or the like is pressed. So if I just move my mouse, functions like OnDrawGizmos or Update do not get called. Coroutines don’t work since they are based on Unity’s internal framerate.
How can I set a constant frame rate in the editor?
Incase this didn’t quite make sense, here’s my code :
void OnDrawGizmos()
{
Ray ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
var plane = new Plane(upV, point);
float distance;
if (plane.Raycast(ray, out distance))
{
var hitPos = ray.origin + distance*ray.direction;
Gizmos.DrawGUITexture(new Rect(hitPos.x- brushSize/2f,
hitPos.y+brushSize/2f, brushSize, -brushSize),
stencils[stencilIndex].texture, gizmoMaterial);
}
}
which only gets called when a button is pressed, not when I just move my mouse.
Any help would be appreciated.