Skip to content

Commit

Permalink
Added Ctrl-NumPadDivide to toggle timed collection independently of t…
Browse files Browse the repository at this point in the history
…he window state
  • Loading branch information
Gerry1135 committed May 12, 2016
1 parent 76b2325 commit 3848acc
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions GrumpyCollector.cs
Expand Up @@ -15,12 +15,13 @@ public class GrumpyCollector : MonoBehaviour
private Rect windowPos = new Rect(40, 40, 150, 46);
private Rect windowDragRect = new Rect(0, 0, 150, 46);

private Rect labelRectInterval = new Rect(10, 18, 70, 20);
private Rect labelRectRate = new Rect(90, 18, 50, 20);
private Rect labelRectInterval = new Rect(10, 18, 80, 20);
private Rect labelRectRate = new Rect(92, 18, 48, 20);

private float interval = 0f;
private string strInterval;

[Persistent] private bool enableGC = false;
[Persistent] private int intervalIdx = 2;

private float lastGC = 0;
Expand Down Expand Up @@ -56,6 +57,10 @@ void Update()
{
showUI = !showUI;
}
if (Input.GetKeyDown(KeyCode.KeypadDivide))
{
enableGC = !enableGC;
}
if (Input.GetKeyDown(KeyCode.KeypadPlus))
{
intervalIdx--;
Expand All @@ -76,7 +81,7 @@ void Update()
}
}

if (showUI && Time.realtimeSinceStartup > lastGC + interval)
if (enableGC && (Time.realtimeSinceStartup > lastGC + interval))
{
GC.Collect(0, GCCollectionMode.Forced);
lastGC = Time.realtimeSinceStartup;
Expand All @@ -97,7 +102,7 @@ public void OnGUI()

public void WindowGUI(int windowID)
{
GUI.Label(labelRectInterval, "GC Interval:");
GUI.Label(labelRectInterval, enableGC ? "GC Enabled:" : "GC Disabled:");
GUI.Label(labelRectRate, strInterval);
GUI.DragWindow(windowDragRect);
}
Expand Down

0 comments on commit 3848acc

Please sign in to comment.