Did a few things
This commit is contained in:
60
Assets/UserReporting/Scripts/FramerateMonitor.cs
Normal file
60
Assets/UserReporting/Scripts/FramerateMonitor.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a behavior that monitors the application for framerate issues and automatically submits a user report.
|
||||
/// </summary>
|
||||
public class FramerateMonitor : UserReportingMonitor
|
||||
{
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="FramerateMonitor"/> class.
|
||||
/// </summary>
|
||||
public FramerateMonitor()
|
||||
{
|
||||
this.MaximumDurationInSeconds = 10;
|
||||
this.MinimumFramerate = 15;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
|
||||
private float duration;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum duration in seconds.
|
||||
/// </summary>
|
||||
public float MaximumDurationInSeconds;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the minimum framerate.
|
||||
/// </summary>
|
||||
public float MinimumFramerate;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
|
||||
private void Update()
|
||||
{
|
||||
float deltaTime = Time.deltaTime;
|
||||
float framerate = 1.0f / deltaTime;
|
||||
if (framerate < this.MinimumFramerate)
|
||||
{
|
||||
this.duration += deltaTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.duration = 0;
|
||||
}
|
||||
|
||||
if (this.duration > this.MaximumDurationInSeconds)
|
||||
{
|
||||
this.duration = 0;
|
||||
this.Trigger();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
Reference in New Issue
Block a user