您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
38 行
966 B
38 行
966 B
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace GameOptionsUtility
|
|
{
|
|
[RequireComponent(typeof(Slider))]
|
|
public class SliderTargetFramerate : MonoBehaviour
|
|
{
|
|
public Vector2 MinMaxFramerate = new Vector2(15, 144);
|
|
|
|
private void OnEnable()
|
|
{
|
|
var slider = GetComponent<Slider>();
|
|
InitializeEntries(slider);
|
|
slider.onValueChanged.AddListener(UpdateOptions);
|
|
UpdateOptions(slider.value);
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
GetComponent<Slider>().onValueChanged.RemoveListener(UpdateOptions);
|
|
}
|
|
|
|
void InitializeEntries(Slider slider)
|
|
{
|
|
slider.value = GameOption.Get<GraphicOption>().targetFrameRate;
|
|
}
|
|
|
|
void UpdateOptions(float value)
|
|
{
|
|
GameOption.Get<GraphicOption>().targetFrameRate = (int)value;
|
|
}
|
|
}
|
|
|
|
}
|
|
|