DelayExample.cs 589 B

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using UnityEngine;
  3. namespace QFramework.Example.ActionKit
  4. {
  5. public class DelayExample : MonoBehaviour
  6. {
  7. void Start()
  8. {
  9. Debug.Log("当前时间为:" + DateTime.Now );
  10. // 对象模式
  11. var delay = DelayAction.Allocate(3, () =>
  12. {
  13. Debug.Log("延时了 3 秒");
  14. Debug.Log("当前时间为:" + DateTime.Now );
  15. });
  16. // 执行 delay 节点
  17. this.ExecuteNode(delay);
  18. // 简化版本(直接执行)
  19. this.Delay(5, () =>
  20. {
  21. Debug.Log("延时了 5 秒");
  22. Debug.Log("当前时间为:" + DateTime.Now );
  23. });
  24. }
  25. }
  26. }