HKI Core
UIAntiAliasingDropdown.cs
Go to the documentation of this file.
1 using UnityEngine;
2 using TMPro;
3 using System.Collections.Generic;
4 using HKI.Core.Loc;
5 using HKI.Core.Settings;
6 
7 namespace HKI.Core.UI.Settings
8 {
12  [RequireComponent(typeof(TMP_Dropdown))]
13  public class UIAntiAliasingDropdown : MonoBehaviour
14  {
15  // Public variables
16  [SerializeField] Language Language = null;
17  [SerializeField] List<TextLocalization> AntiAliasingModeTextLocalizations = new List<TextLocalization>();
18  [SerializeField] AntiAliasingMode AntiAliasingMode = null;
19 
20  // Private variables
21  TMP_Dropdown dropdown = null;
22 
23  // Awake function
24  void Awake()
25  {
26  dropdown = GetComponent<TMP_Dropdown>();
27  }
28 
29  // OnEnable function
30  void OnEnable()
31  {
32  if(AntiAliasingMode != null)
33  {
34  List<TMP_Dropdown.OptionData> list = new List<TMP_Dropdown.OptionData>();
35  for (int i = 0; i < AntiAliasingModeTextLocalizations.Count; i++)
36  list.Add(new TMP_Dropdown.OptionData(AntiAliasingModeTextLocalizations[i].GetText(Language)));
37 
38  dropdown.ClearOptions();
39  dropdown.AddOptions(list);
40 
41  dropdown.value = (int)AntiAliasingMode.Value;
42  }
43  else
44  Debug.LogError("(UIAntiAliasingDropdown) AntiAliasingMode value is null!");
45  }
46 
47  // Interface functions
49  {
50  if(AntiAliasingMode != null)
51  AntiAliasingMode.SetValue = (AntiAliasingModes)dropdown.value;
52  }
53 
54  public void Reset()
55  {
56  List<TMP_Dropdown.OptionData> list = new List<TMP_Dropdown.OptionData>();
57  for (int i = 0; i < AntiAliasingModeTextLocalizations.Count; i++)
58  list.Add(new TMP_Dropdown.OptionData(AntiAliasingModeTextLocalizations[i].GetText(Language)));
59 
60  dropdown.ClearOptions();
61  dropdown.AddOptions(list);
62 
63  dropdown.value = (int)AntiAliasingMode.Value;
64  }
65  }
66 }
Special Variable enables the use of the AntiAliasingModes data type as a variable of the settings sys...
AntiAliasingModes
All possible settings for anti aliasing.
Special Variable enables the use of the SystemLanguage data type as a variable of the settings system...
Definition: Language.cs:13
This MonoBehaviour fills and handles a dropdown (TMP_Dropdown) with anti aliansing settings...