2022-09-10 12:36:37 +03:00
|
|
|
using UnityEngine;
|
|
|
|
|
|
2022-11-03 13:09:06 +02:00
|
|
|
public class DemonicsWorld : MonoBehaviour
|
2022-09-10 12:36:37 +03:00
|
|
|
{
|
2023-01-02 19:59:46 +02:00
|
|
|
[SerializeField] private int _frameRate = 60;
|
|
|
|
|
[SerializeField] private bool _vSync = true;
|
2022-09-14 23:06:52 +03:00
|
|
|
public static int Frame;
|
2022-09-10 12:36:37 +03:00
|
|
|
|
|
|
|
|
|
2022-09-14 23:06:52 +03:00
|
|
|
void Awake()
|
|
|
|
|
{
|
2023-01-02 19:59:46 +02:00
|
|
|
Application.targetFrameRate = _frameRate;
|
|
|
|
|
QualitySettings.vSyncCount = _vSync ? 1 : 0;
|
2022-09-14 23:06:52 +03:00
|
|
|
Time.fixedDeltaTime = 0.01667f;
|
2022-11-17 17:01:21 +02:00
|
|
|
Frame = 0;
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
2022-09-10 12:36:37 +03:00
|
|
|
|
2022-09-14 23:06:52 +03:00
|
|
|
public static bool WaitFrames(ref int frames)
|
|
|
|
|
{
|
|
|
|
|
frames--;
|
|
|
|
|
if (frames <= 0)
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool WaitFramesOnce(ref int frames)
|
|
|
|
|
{
|
|
|
|
|
frames--;
|
|
|
|
|
if (frames == 0)
|
|
|
|
|
return true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2023-01-08 18:48:39 +02:00
|
|
|
|
|
|
|
|
public static void SetFramerate(int framerate, bool vSync = true)
|
|
|
|
|
{
|
|
|
|
|
Application.targetFrameRate = framerate;
|
|
|
|
|
QualitySettings.vSyncCount = vSync ? 1 : 0;
|
|
|
|
|
}
|
2022-09-10 12:36:37 +03:00
|
|
|
}
|