private void SetBestThreshold()
    {
        int  maxFound        = thresholds.Max(threshold => threshold.visibleMarkers);
        int  bestStart       = 0;
        int  bestEnd         = 0;
        int  currentStart    = 0;
        bool newSectionFound = false;

        for (int i = 0; i < thresholds.Length; i++)
        {
            VisibilityForThreshold threshold = thresholds[i];
            if (threshold.visibleMarkers != maxFound && newSectionFound)
            {
                int currentEnd = i - 1;
                if (Length(currentStart, currentEnd) > Length(bestStart, bestEnd))
                {
                    bestStart = currentStart;
                    bestEnd   = currentEnd;
                }
                newSectionFound = false;
            }
            else if (threshold.visibleMarkers == maxFound && newSectionFound == false)
            {
                currentStart    = i;
                newSectionFound = true;
            }
        }
        arController.VideoThreshold = (int)Mathf.Lerp(bestStart, bestEnd, 0.5f);
        isRunning = false;
        if (notifierText != null)
        {
            notifierText.NotifyThresholdAdjusterFinished(arController.VideoThreshold);
        }
    }
    IEnumerator CheckVisibility(float time, int threshold)
    {
        yield return(new WaitForSeconds(time));

        int totalVisible = markers.Count(marker => marker.Visible);

        thresholds[threshold] = new VisibilityForThreshold(threshold, totalVisible);
        if (threshold == 255)
        {
            SetBestThreshold();
        }
    }