64 lines
1.7 KiB
C#
64 lines
1.7 KiB
C#
using RTG;
|
|
using System;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.Rendering;
|
|
using UnityEngine.UI;
|
|
using WI;
|
|
using WI.UI;
|
|
|
|
|
|
namespace XED.UI
|
|
{
|
|
public class Panel_AccessibilitySettings : PanelBase
|
|
{
|
|
public RTSceneGrid rtSceneGrid;
|
|
|
|
// GridSystems
|
|
public Slider Slider;
|
|
public TextMeshProUGUI Text_Size;
|
|
public Image Image_CurrentColor;
|
|
public Button Button_ChangeGridColor;
|
|
public float unit = 0.1f;
|
|
public event Action<Color> onClickChangeGridColor;
|
|
|
|
public override void AfterAwake()
|
|
{
|
|
rtSceneGrid = FindFirstObjectByType<RTSceneGrid>();
|
|
|
|
Slider.minValue = 0.1f;
|
|
Slider.maxValue = 5f; ;
|
|
Slider.onValueChanged.AddListener(OnValueChangedSlider);
|
|
Button_ChangeGridColor.onClick.AddListener(OnClickChangeGridColor);
|
|
|
|
Init();
|
|
}
|
|
|
|
private void Init()
|
|
{
|
|
Slider.value = rtSceneGrid.Settings.CellSizeX;
|
|
Image_CurrentColor.color = rtSceneGrid.LookAndFeel.LineColor;
|
|
}
|
|
|
|
private void OnValueChangedSlider(float value)
|
|
{
|
|
float roundValue = Mathf.Round(value / unit) * unit;
|
|
Slider.value = roundValue;
|
|
Text_Size.text = roundValue.ToString("0.0");
|
|
rtSceneGrid.Settings.CellSizeX = roundValue;
|
|
}
|
|
|
|
private void OnClickChangeGridColor()
|
|
{
|
|
onClickChangeGridColor?.Invoke(rtSceneGrid.LookAndFeel.LineColor);
|
|
}
|
|
|
|
public void onChangeColor(Color color)
|
|
{
|
|
rtSceneGrid.LookAndFeel.LineColor = color;
|
|
Image_CurrentColor.color = color;
|
|
}
|
|
|
|
}
|
|
}
|