大家好,我有一个我无法解决的问题。我希望变量top取决于变量money的值sub。
例如:如果变量subexample 的数字为548,则该变量的money每秒暂停次数变为0.4f yield return new WaitForSeconds(0.4f);并且该变量的top每秒暂停次数变为4yield return new WaitForSeconds(5);。也就是说,变量 中的数字越大,变量和sub中的数字集合就越快topmoney。
像这样的东西。这是整个代码:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Game : MonoBehaviour
{
public Text sub;
public int score;
public Text money;
public int score1;
public Text top;
public int score2;
void Start()
{
StartCoroutine(CountPoints());
StartCoroutine(CountPoints1());
StartCoroutine(CountPoints2());
}
IEnumerator CountPoints()
{
while (score < 10000)
{
sub.text = score.ToString();
score++;
yield return new WaitForSeconds(1);
}
}
IEnumerator CountPoints1()
{
while (score1 < 10000)
{
money.text = score1.ToString();
score1++;
yield return new WaitForSeconds(0.5f);
}
}
IEnumerator CountPoints2()
{
while (score2 > 0)
{
top.text = score2.ToString();
score2--;
yield return new WaitForSeconds(5);
}
}
}
我已经忘记了锐化,所以我用伪代码编写:
线性函数是什么样的,你可以看看维基百科
因此,您将它们作为参数传递
WaitForSeconds(topDelay);好吧,因此,没有人知道你需要写什么线性函数,因为只有你知道你想要增加或减少什么依赖
topDelay,并且moneyDelay相对sub