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

public class intensity_value : MonoBehaviour
{
    [SerializeField] private Light lightComponent; //you can remove if you will not use
    [SerializeField] private CheckBottomOfModel bottom;
    [SerializeField] private Text textIntensity;
    [SerializeField] private Button fileButton, layerButton;
    [SerializeField] private Slider sliderIntensity;
    [SerializeField] private RoscanModelUnity model;

    // initialization
   // private void Start()
   // {
    //    modelRen = GetComponent<Renderer>();
   // }

    /// <summary> Set intenzity of Light to shader </summary>
    public void IntensityValue(float value)
    {
        bottom.modelRen.material.SetFloat("_xAmbient", value);
        textIntensity.text = value.ToString("0.00");
    }

    /// <summary> On changing the layer set intenzity of Light to default (0) </summary>
    public void IntensityDefault()
    {
        if(layerButton != null)
        {
            sliderIntensity.value = 0;
            bottom.modelRen.material.SetFloat("_xAmbient", 0);
        }
    }
    
    /// <summary> When the new model is opened, reset the intensity of the light </summary>
    public void InvokeButton()
    {
        if (fileButton != null)
        {
            if (model.ActualLayer != RoscanModelUnity.ModelLayers.SURFACE)
                layerButton.onClick.Invoke();
            else
                IntensityDefault();
        }
    }
}
