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

public class PhotonGameDebugger : MonoBehaviour {


	static int numberOfMessages = 0;
	float nextTimeToDebug = 0.0f;
	// always waiting one second to debug
	public bool enableDebug;
	public bool enableDebugName;

	public static bool debug;
	public static bool debugName; // in order to debug name the normal debug also needs to be on

	void Start() {
		debug = enableDebug;
		debugName = enableDebugName;
	}

	// Update is called once per frame
	void Update () {
		debug = enableDebug;
		debugName = enableDebugName;
		if (Time.unscaledTime > nextTimeToDebug) {
			if(debug)
				Debug.LogError("Messages sent this second: " + numberOfMessages);
			nextTimeToDebug = Time.unscaledTime + 1.0f;
			numberOfMessages = 0;
		}
	}

	public static void IncrementNumberOfMessages(string name = "") {
		if(name != "" && debug && debugName) {
			Debug.LogError(name);
		}
		numberOfMessages++;
	}
}
