C# 如何使用特定速度变量缩放变换?

C# 如何使用特定速度变量缩放变换?,c#,unity3d,unity5,C#,Unity3d,Unity5,trans=变换 我想以特定的速度缩放它。我的意思是使用新的Vector3,但要使它更快 在启动函数中 IEnumerator scaleCube(Transform trans) { while (true) { trans.localScale += new Vector3(0.1f, 0.1f, 0); yield return null; } } 我有一个公共的全球浮动速度变

trans=变换 我想以特定的速度缩放它。我的意思是使用新的Vector3,但要使它更快

在启动函数中

IEnumerator scaleCube(Transform trans)
    {
        while (true)
        {
            trans.localScale += new Vector3(0.1f, 0.1f, 0);
            yield return null;
        }
    }
我有一个公共的全球浮动速度变量。
如何使用带有刻度的速度变量来控制刻度速度?

创建一个速度变量,然后将其乘以。就这么简单

StartCoroutine(scaleCube(cube.transform));
当您增加
速度
变量的值时,缩放速度会增加

public float speed = 2f;

IEnumerator scaleCube(Transform trans)
{
    while (true)
    {
        trans.localScale += new Vector3(speed * Time.deltaTime, speed * Time.deltaTime, 0);
        yield return null;
    }
}