Advertisement
Guest User

Untitled

a guest
May 28th, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public static class _Time
  5. {
  6. private static int iLastFrame = 0;
  7. private static float fLastTime = 0.0f;
  8. private static float fDeltaTime = 0.0f;
  9.  
  10. // 初期化:Start() で実行
  11. public static void StartDeltaTime()
  12. {
  13. fLastTime = Time.realtimeSinceStartup;
  14. iLastFrame = Time.frameCount;
  15. }
  16.  
  17. // 更新:Update() で実行
  18. public static void UpdateDeltaTime()
  19. {
  20. int iCurrentFrame = Time.frameCount;
  21. if (iCurrentFrame != iLastFrame)
  22. {
  23. float fCurrentTime = Time.realtimeSinceStartup;
  24. fDeltaTime = fCurrentTime - fLastTime;
  25. fLastTime = fCurrentTime;
  26. iLastFrame = iCurrentFrame;
  27. }
  28. }
  29.  
  30. // 取得:Time.deltaTime を _Time.deltaTime に置き換えて使用する
  31. public static float deltaTime
  32. {
  33. get {
  34. if (Time.timeScale == 0) return fDeltaTime;
  35. else return Time.deltaTime;
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement