SplashUtils.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using UnityEditor;
  5. using UnityEngine;
  6. public class SplashUtils
  7. {
  8. [MenuItem("SDK/SetSplashImage")]
  9. public static void SetSplashImage()
  10. {
  11. PlayerSettings.SplashScreen.show = true;
  12. PlayerSettings.SplashScreen.backgroundColor = Color.black;
  13. PlayerSettings.SplashScreenLogo[] logos = PlayerSettings.SplashScreen.logos;
  14. var logo = new PlayerSettings.SplashScreenLogo();
  15. string splashAssetPath = AssetDatabase.GUIDToAssetPath(AssetDatabase.FindAssets("SplashImg")[0]);
  16. logo.duration = 2f;
  17. logo.logo = AssetDatabase.LoadAssetAtPath<Sprite>(splashAssetPath);
  18. if (logos == null)
  19. {
  20. logos = new PlayerSettings.SplashScreenLogo[] { logo };
  21. }
  22. else
  23. {
  24. List<PlayerSettings.SplashScreenLogo> logoList = new List<PlayerSettings.SplashScreenLogo>(logos);
  25. logoList.Add(logo);
  26. logos = logoList.ToArray();
  27. }
  28. PlayerSettings.SplashScreen.logos = logos;
  29. }
  30. }