繁体   English   中英

如何使动画在Unity中多次播放?

[英]How to get animation to play multiple times in Unity?

我想让精灵来播放一次单击时滴下的水滴的动画,但是该动画仅在我第一次单击时播放,我不知道为什么。

这是精灵上使用的代码:

public class PipetteScript : MonoBehaviour {

public Animator pipetteAnim;
public BoxCollider2D pipetteMove;
public IndicatorScript indicator;

// Use this for initialization
void Start () {
    pipetteAnim.enabled = true;
    pipetteMove.enabled = true;
    indicator.enabled = true;
}

void OnMouseDown () {
    pipetteAnim.Play ("Pipette_dropping");
    Debug.Log ("Anim playing");
    }
}

每次我单击精灵时,调试日志甚至会打印出“正在播放动画”。

在更新功能中使用动画,然后让我更新

public class PipetteScript : MonoBehaviour {
public Animator pipetteAnim;
public BoxCollider2D pipetteMove;
public IndicatorScript indicator;
public bool boolval = false;

// Use this for initialization
void Start () {
    pipetteAnim.enabled = true;
    pipetteMove.enabled = true;
    indicator.enabled = true;
}
void update()
{
 if(boolval == true)
   pipetteAnim.Play ("Pipette_dropping");
 if(boolval == false)
   pipetteAnim.Stop ("Pipette_dropping");
}
void OnMouseDown () {
    boolval = True;
    }
void OnMouseUp () {
    boolval = False;
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM