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

public class DistanceOptionDisplay : MonoBehaviour
{
	[Header("Setting Descriptions")]
    [SerializeField] string[] displayTexts;

	[Header("Debug")]
	[SerializeField] DebugChannelSO m_debugChannel;

    public void UpdateDisplayText(Slider _slider)
    {
        if (_slider == null || displayTexts.Length == 0)
            return;

        float _perc = (_slider.value - _slider.minValue) / (_slider.maxValue - _slider.minValue);

        int _selection = Mathf.RoundToInt((displayTexts.Length - 1) * _perc);

	    if (m_debugChannel)
		    m_debugChannel.Raise(this, "Render distance set to level " + _selection);

        GetComponent<TextMeshProUGUI>().text = displayTexts[_selection];
    }
}
