LuaProfiler.cs 721 B

1234567891011121314151617181920212223242526272829303132333435
  1. using System.Collections.Generic;
  2. using UnityEngine;
  3. #if UNITY_5_5_OR_NEWER
  4. using UnityEngine.Profiling;
  5. #endif
  6. namespace LuaInterface
  7. {
  8. public static class LuaProfiler
  9. {
  10. public static List<string> list = new List<string>();
  11. public static void Clear()
  12. {
  13. list.Clear();
  14. }
  15. public static int GetID(string name)
  16. {
  17. int id = list.Count;
  18. list.Add(name);
  19. return id;
  20. }
  21. public static void BeginSample(int id)
  22. {
  23. string name = list[id];
  24. Profiler.BeginSample(name);
  25. }
  26. public static void EndSample()
  27. {
  28. Profiler.EndSample();
  29. }
  30. }
  31. }