using UnityEngine;
using UnityEngine.UI;
using TMPro;
using GhostSystem;

public class VRDebugger : MonoBehaviour
{
    public TMP_Text trackedObjects;
    public TMP_Text recording;

    public EyeTrackingCollisionPoints collisionPoints;

    private void OnEnable()
    {
        LocalPlayerReference.OnPlayerReady += GetTrackedObjects;
        GhostRecorderBatch.OnRecord += RecordingStart;
        GhostRecorderBatch.OnStopRecord += RecordingStop;
    }

    private void OnDisable()
    {
        LocalPlayerReference.OnPlayerReady -= GetTrackedObjects;
        GhostRecorderBatch.OnRecord -= RecordingStart;
        GhostRecorderBatch.OnStopRecord -= RecordingStop;
    }
    private void Start() // Nur für Offline Mode
    {
        GetTrackedObjects();
    }

    private void GetTrackedObjects()
    {
        GhostRecorderBatch ghostRecorder = FindFirstObjectByType<GhostRecorderBatch>();
        foreach (var obj in ghostRecorder.TrackedObjects)
        {
            trackedObjects.text += "\n\r" + obj;
        }
    }

    private void RecordingStart()
    {
        recording.color = Color.white;
        recording.text = "Recording...";
    }

    private void RecordingStop()
    {
        recording.color = Color.white;
        recording.text = "...";
    }
}
