35 lines
799 B
C#
35 lines
799 B
C#
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using AYellowpaper.SerializedCollections;
|
||
|
using UnityEngine;
|
||
|
|
||
|
namespace BITKit
|
||
|
{
|
||
|
public class SetTargetFrameRate : MonoBehaviour
|
||
|
{
|
||
|
[SerializeField] private SerializedDictionary<string, int> frameRateDictionary;
|
||
|
[SerializeField] private int startFrameRate;
|
||
|
private int currentFrameRate;
|
||
|
private void Start()
|
||
|
{
|
||
|
currentFrameRate = Application.targetFrameRate;
|
||
|
}
|
||
|
public void SetFrameRate(string key)
|
||
|
{
|
||
|
if (frameRateDictionary.TryGetValue(key, out var frameRate))
|
||
|
{
|
||
|
SetFrameRate(frameRate);
|
||
|
}else if (int.TryParse(key, out frameRate))
|
||
|
{
|
||
|
SetFrameRate(frameRate);
|
||
|
}
|
||
|
}
|
||
|
public void SetFrameRate(int frameRate)
|
||
|
{
|
||
|
Application.targetFrameRate =currentFrameRate = frameRate;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|