SamplesCallBackHelper.cs 740 B

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace SC.XR.Unity.Module_PerformanceSampler
  5. {
  6. //回调发布
  7. public class SamplesCallBackHelper:MonoBehaviour
  8. {
  9. private Action mainThreadAction = null;
  10. private void Awake()
  11. {
  12. DontDestroyOnLoad(gameObject);
  13. }
  14. private void Update()
  15. {
  16. if (mainThreadAction != null)
  17. {
  18. Action temp = mainThreadAction;
  19. mainThreadAction = null;
  20. temp.Invoke();
  21. }
  22. }
  23. public void CallonMainThread(Action function)
  24. {
  25. mainThreadAction = function;
  26. }
  27. }
  28. }