Sin descripción
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NGCallbackHelper.cs 604B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #if UNITY_EDITOR || UNITY_ANDROID
  2. using UnityEngine;
  3. namespace NativeGalleryNamespace
  4. {
  5. public class NGCallbackHelper : MonoBehaviour
  6. {
  7. private System.Action mainThreadAction = null;
  8. private void Awake()
  9. {
  10. DontDestroyOnLoad( gameObject );
  11. }
  12. private void Update()
  13. {
  14. if( mainThreadAction != null )
  15. {
  16. try
  17. {
  18. System.Action temp = mainThreadAction;
  19. mainThreadAction = null;
  20. temp();
  21. }
  22. finally
  23. {
  24. Destroy( gameObject );
  25. }
  26. }
  27. }
  28. public void CallOnMainThread( System.Action function )
  29. {
  30. mainThreadAction = function;
  31. }
  32. }
  33. }
  34. #endif