30 lines
637 B
C#
30 lines
637 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class GameTimeController : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private float _currentTimeScale = 0;
|
|
|
|
private void Start()
|
|
{
|
|
UpdateTime();
|
|
}
|
|
|
|
public void ChangeTime(float value, float time = 1)
|
|
{
|
|
var startValue = _currentTimeScale;
|
|
LeanTween.value(startValue, value, time).setIgnoreTimeScale(true).setOnUpdate((float x)=>
|
|
{
|
|
_currentTimeScale = x;
|
|
UpdateTime();
|
|
});
|
|
}
|
|
|
|
private void UpdateTime()
|
|
{
|
|
Time.timeScale = _currentTimeScale;
|
|
}
|
|
}
|