如題:
我已經用了 FixedUpdate 了怎么時間還是慢半拍的?有什么解決方法嗎?
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
public class Spawner : MonoBehaviour
{
public RadialSlider slider;
public Button button;
void Start()
{
button.onClick.AddListener(OnClick);
button.interactable = true;
slider.timeRemaining = slider.maxTime;
}
void OnClick()
{
StartCoroutine(OnFixedUpdateRoutine());
}
IEnumerator OnFixedUpdateRoutine()
{
slider.timeRemaining = slider.maxTime;
button.interactable = false;
float fixedDeltaTime = Time.fixedDeltaTime;
for(float t = slider.maxTime; t > 0; t -= Time.fixedDeltaTime)
//for(float t = 0; t < slider.maxTime ; t += fixedDeltaTime)
{
slider.timeRemaining = t;
yield return new WaitForSeconds(fixedDeltaTime);
}
slider.timeRemaining = Time.time;
button.interactable = true;
}
}
uj5u.com熱心網友回復:
什么叫慢半拍?我不知道你在做什么,也不大可能提出什么有益的建議。不過 從字面上看 WaitForSeconds 是延時若干秒,既然有延時,慢一點就是正常的
uj5u.com熱心網友回復:
就是倒數的時候,比正常的秒數慢
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/282051.html
標籤:C#
