SkipSplash.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. /* ---------------------------------------------------------------- */
  2. /* Skip Unity Splash Screen */
  3. /* Create by psygames */
  4. /* https://github.com/psygames/UnitySkipSplash */
  5. /* ---------------------------------------------------------------- */
  6. #if !UNITY_EDITOR
  7. using UnityEngine;
  8. using UnityEngine.Rendering;
  9. public class SkipSplash
  10. {
  11. [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSplashScreen)]
  12. private static void BeforeSplashScreen()
  13. {
  14. #if UNITY_WEBGL
  15. Application.focusChanged += Application_focusChanged;
  16. #else
  17. System.Threading.Tasks.Task.Run(AsyncSkip);
  18. #endif
  19. }
  20. #if UNITY_WEBGL
  21. private static void Application_focusChanged(bool obj)
  22. {
  23. Application.focusChanged -= Application_focusChanged;
  24. SplashScreen.Stop(SplashScreen.StopBehavior.StopImmediate);
  25. }
  26. #else
  27. private static void AsyncSkip()
  28. {
  29. SplashScreen.Stop(SplashScreen.StopBehavior.StopImmediate);
  30. }
  31. #endif
  32. }
  33. #endif