LuaProfiler.cs 604 B

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