Skip to content

Commit

Permalink
Don't list fps counter itself
Browse files Browse the repository at this point in the history
  • Loading branch information
ManlyMarco committed Sep 14, 2019
1 parent a1e7076 commit a62bf92
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 4 additions & 1 deletion FPSCounter/FPSCounter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ private void SetCapturingEnabled(bool enableCapturing, bool create)
}

if (_pluginStats.Value)
PluginCounter.Start(_helpers[0]);
{
// Make it start its coroutine on a helper so it gets disabled
PluginCounter.Start(_helpers[0], this);
}

_helpers[0].enabled = enableCapturing;
_helpers[1].enabled = enableCapturing;
Expand Down
11 changes: 8 additions & 3 deletions FPSCounter/PluginCounter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal static class PluginCounter

public static string StringOutput { get; private set; }

public static void Start(MonoBehaviour mb)
public static void Start(MonoBehaviour mb, BaseUnityPlugin thisPlugin)
{
if (_running) return;
_running = true;
Expand All @@ -35,7 +35,7 @@ public static void Start(MonoBehaviour mb)
// Hook unity event methods on all plugins
var baseType = typeof(MonoBehaviour);
var unityMethods = new[] { "FixedUpdate", "Update", "LateUpdate", "OnGUI" };
foreach (var baseUnityPlugin in Chainloader.Plugins.Where(x => x != null))
foreach (var baseUnityPlugin in Chainloader.Plugins.Where(x => x != null && x != thisPlugin))
{
var timer = new Stopwatch();

Expand Down Expand Up @@ -83,6 +83,8 @@ public static void Stop()
_averages.Clear();

_stopAction();

StringOutput = null;
}

private static IEnumerator CollectLoop()
Expand Down Expand Up @@ -116,7 +118,10 @@ private static IEnumerator CollectLoop()
.Take(5)
.ToList();

StringOutput = string.Join(" | ", toShow.Select(timer => $"{timer.Key.GUID}: {timer.Value * msScale,5:0.00}ms").ToArray());
if (toShow.Count == 0)
StringOutput = "No slow plugins";
else
StringOutput = string.Join(" | ", toShow.Select(timer => $"{timer.Key.GUID}: {timer.Value * msScale,5:0.00}ms").ToArray());

foreach (var timer in _timers)
timer.Value.Value.Reset();
Expand Down

0 comments on commit a62bf92

Please sign in to comment.