【问题标题】:Animation is not smooth on devices设备上的动画不流畅
【发布时间】:2016-07-08 11:43:34
【问题描述】:

我想通过更改 RawImage 的 uvRect.y 来为纹理设置动画。

public class animation : MonoBehaviour {

public RawImage image;
public Text text;

private Rect rect;

// Use this for initialization
void Start () {
    Application.targetFrameRate = 60;
    rect = image.uvRect;
}

// Update is called once per frame
void FixedUpdate () {
    rect.y += (Time.fixedDeltaTime*0.1f);
    text.text = (Time.fixedDeltaTime * 0.1f).ToString() + "  :   " + Time.fixedDeltaTime + "  :  "+image.uvRect.y;
    image.uvRect = rect;
}
}

在 Unity 的编辑器中动画很流畅,但在设备(iOS 或 Android)上却不是。 场景中没有其他脚本,所以 CPU 没有加载太多导致动画不流畅。

那么为什么会这样以及如何解决呢?

【问题讨论】:

    标签: android ios unity3d


    【解决方案1】:

    因为你使用了FixedUpdate()。尝试改用Update()。 FixedUpdate 应该用于物理操作。

    您还应该将Time.fixedDeltaTime 更改为Time.deltaTime

    FixedUpdate 取决于您可以在编辑器中设置的物理步骤。但是Update 是基于 FPS 的,所以你的动画会比FixedUpdate 更流畅。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-04-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-10-30
      • 2010-11-07
      • 2017-07-01
      • 1970-01-01
      相关资源
      最近更新 更多