using System.Collections;
using System.Collections.Generic;
using UnityEngine;


/// <summary>
/// Helper class to calculate fps
/// </summary>
public class FPSCounter : MonoBehaviour {

    private bool _counting = false;

    public int FramesElapsed { get; private set; }

    public float TimeElapsed { get; private set; }

    public float AverageFPS {
        get
        {
            return FramesElapsed / (TimeElapsed);
        }
    }


    public void StartCounter()
    {
        _counting = true;
    }

    public void StopCounter()
    {
        _counting = false;
    }

    public void ResetCounter()
    {
        TimeElapsed = 0;
        FramesElapsed = 0;
        _counting = false;
    }

    

    private void Update()
    {
        if (_counting)
        {
            FramesElapsed++;
            TimeElapsed += Time.unscaledDeltaTime;
        }
    }
}
