我正在用一些动画编写游戏,并在用户单击按钮时使用这些动画。我想向用户展示动画,而不是“只”用Application.loadLevel调用新的关卡。我想我可以在onMouseUp方法中使用Time.DeltaTime并将其添加到预定义的0f值,然后检查它是否大于(例如)1f,但它不会工作,因为onMouseUp方法只会添加“它是自己的时间“作为德尔塔时间。如何等待几秒钟,然后在OnMouseUp事件中做点什么
我的脚本看起来现在这个样子:
public class ClickScriptAnim : MonoBehaviour {
public Sprite pressedBtn;
public Sprite btn;
public GameObject target;
public string message;
public Transform mesh;
private bool inAnim = true;
private Animator animator;
private float inGameTime = 0f;
// Use this for initialization
void Start() {
animator = mesh.GetComponent<Animator>();
}
// Update is called once per frame
void Update() {
}
void OnMouseDown() {
animator.SetBool("callAnim", true);
}
void OnMouseUp() {
animator.SetBool("callAnim", false);
animator.SetBool("callGoAway", true);
float animTime = Time.deltaTime;
Debug.Log(inGameTime.ToString());
// I would like to put here something to wait some seconds
target.SendMessage(message, SendMessageOptions.RequireReceiver);
}
}
}
Thread.Sleep(1000)将等待一秒钟,你是否在寻找沿这些线的东西? – Bayeni 2014-10-28 13:33:47
你试图等待一段时间的代码在哪里? – Reniuz 2014-10-28 13:36:09
正如我写的,我试图把一个inGameTime + = Time.deltaTime放到onMouseUp()方法中,但它不能像预期的那样工作,因为OnMouseUp方法只返回最小的deltaTime – Zwiebel 2014-10-28 13:43:41