42 lines
1.1 KiB
C#
42 lines
1.1 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
public class TestUI : MonoBehaviour
|
|
{
|
|
public TMP_Dropdown QualityDropdown;
|
|
public TMP_Dropdown waterSwitch;
|
|
|
|
public GameObject[] Waters;
|
|
|
|
private void OnEnable()
|
|
{
|
|
InitDropdown();
|
|
}
|
|
|
|
private void InitDropdown()
|
|
{
|
|
QualityDropdown.ClearOptions();
|
|
QualityDropdown.AddOptions(QualitySettings.names.ToList());
|
|
QualityDropdown.value = QualitySettings.GetQualityLevel();
|
|
QualityDropdown.onValueChanged.AddListener(index => QualitySettings.SetQualityLevel(index));
|
|
|
|
waterSwitch.ClearOptions();
|
|
waterSwitch.AddOptions(Waters.Select(_ => _.name).ToList());
|
|
waterSwitch.value = 0;
|
|
OnWaterChange(0);
|
|
waterSwitch.onValueChanged.AddListener(OnWaterChange);
|
|
}
|
|
|
|
private void OnWaterChange(int index)
|
|
{
|
|
for(int i = 0; i < Waters.Length; i++)
|
|
{
|
|
|
|
Waters[i].SetActive(i == index);
|
|
}
|
|
}
|
|
}
|