您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
139 行
2.8 KiB
139 行
2.8 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Localization;
|
|
using UnityEngine.Localization.Settings;
|
|
|
|
public class UISettingFieldsFiller : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private UISettingItemFiller[] _settingfieldsList = default;
|
|
[SerializeField]
|
|
private InputReader _inputReader = default;
|
|
public void FillFields(List<SettingField> settingItems)
|
|
{
|
|
for (int i = 0; i < _settingfieldsList.Length; i++)
|
|
{
|
|
if (i < settingItems.Count)
|
|
{
|
|
SetField(settingItems[i], _settingfieldsList[i]);
|
|
_settingfieldsList[i].gameObject.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
_settingfieldsList[i].gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
public void SetField(SettingField field, UISettingItemFiller uiField)
|
|
{
|
|
int paginationCount = 0;
|
|
int selectedPaginationIndex = 0;
|
|
string selectedOption = default;
|
|
LocalizedString fieldTitle = field.title;
|
|
SettingFieldType fieldType = field.settingFieldType;
|
|
|
|
switch (field.settingFieldType)
|
|
{
|
|
case SettingFieldType.Language:
|
|
paginationCount = LocalizationSettings.AvailableLocales.Locales.Count;
|
|
selectedPaginationIndex = LocalizationSettings.AvailableLocales.Locales.FindIndex(o => o == LocalizationSettings.SelectedLocale);
|
|
selectedOption = LocalizationSettings.SelectedLocale.LocaleName;
|
|
break;
|
|
case SettingFieldType.AntiAliasing:
|
|
|
|
break;
|
|
case SettingFieldType.FullScreen:
|
|
selectedPaginationIndex = IsFullscreen();
|
|
paginationCount = 2;
|
|
if (Screen.fullScreen)
|
|
selectedOption = "On";
|
|
else
|
|
selectedOption = "Off";
|
|
break;
|
|
case SettingFieldType.ShadowDistance:
|
|
|
|
break;
|
|
case SettingFieldType.Resolution:
|
|
|
|
break;
|
|
case SettingFieldType.ShadowQuality:
|
|
|
|
break;
|
|
case SettingFieldType.Volume_Music:
|
|
case SettingFieldType.Volume_SFx:
|
|
paginationCount = 10;
|
|
selectedPaginationIndex = 5;
|
|
selectedOption = "5";
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
uiField.FillSettingField(paginationCount, selectedPaginationIndex, selectedOption);
|
|
|
|
|
|
}
|
|
string GetQualityLevelTitle()
|
|
{
|
|
string title = "";
|
|
switch (QualitySettings.GetQualityLevel())
|
|
{
|
|
|
|
case (int)QualityLevel.Beautiful:
|
|
title = QualityLevel.Beautiful.ToString();
|
|
break;
|
|
case (int)QualityLevel.Fantastic:
|
|
title = QualityLevel.Fantastic.ToString();
|
|
break;
|
|
case (int)QualityLevel.Fast:
|
|
title = QualityLevel.Fast.ToString();
|
|
|
|
break;
|
|
case (int)QualityLevel.Fastest:
|
|
title = QualityLevel.Fastest.ToString();
|
|
|
|
break;
|
|
case (int)QualityLevel.Good:
|
|
title = QualityLevel.Good.ToString();
|
|
|
|
break;
|
|
case (int)QualityLevel.Simple:
|
|
title = QualityLevel.Simple.ToString();
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
return title;
|
|
|
|
}
|
|
int IsFullscreen()
|
|
{
|
|
if (Screen.fullScreen)
|
|
{
|
|
return 0;
|
|
}
|
|
else
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
}
|
|
int _selectedFieldIndex;
|
|
|
|
void NextField()
|
|
{
|
|
|
|
}
|
|
void PreviousField()
|
|
{
|
|
|
|
|
|
}
|
|
}
|