25 lines
564 B
C#
25 lines
564 B
C#
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
[RequireComponent(typeof(TMP_Dropdown))]
|
|
public class PlayerPrefDropdown : MonoBehaviour
|
|
{
|
|
private TMP_Dropdown _dropdown;
|
|
|
|
[SerializeField]
|
|
private PlayerPrefValue _playerPref;
|
|
|
|
private void Awake()
|
|
{
|
|
_dropdown = GetComponent<TMP_Dropdown>();
|
|
_dropdown.onValueChanged.AddListener( _playerPref.SetInt );
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
int value = _playerPref.GetInt();
|
|
_dropdown.SetValueWithoutNotify( value );
|
|
}
|
|
}
|