using UnityEngine;
///
/// Represents a behavior that monitors the application for framerate issues and automatically submits a user report.
///
public class FramerateMonitor : UserReportingMonitor
{
#region Constructors
///
/// Creates a new instance of the class.
///
public FramerateMonitor()
{
this.MaximumDurationInSeconds = 10;
this.MinimumFramerate = 15;
}
#endregion
#region Fields
private float duration;
///
/// Gets or sets the maximum duration in seconds.
///
public float MaximumDurationInSeconds;
///
/// Gets or sets the minimum framerate.
///
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
}