27 lines
605 B
C#
27 lines
605 B
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
[RequireComponent(typeof(Slider))]
|
|
public class PlayerPrefSlider : MonoBehaviour
|
|
{
|
|
private Slider _slider;
|
|
|
|
[SerializeField]
|
|
private PlayerPrefValue _playerPref;
|
|
|
|
private void Awake()
|
|
{
|
|
_slider = GetComponent<Slider>();
|
|
_slider.onValueChanged.AddListener( _playerPref.SetFloat );
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
float value = _playerPref.GetFloat();
|
|
_slider.SetValueWithoutNotify( value );
|
|
}
|
|
}
|