簡體   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