RateStaticMeshCombiner.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #if UNITY_EDITOR
  2. using UnityEngine;
  3. using UnityEditor;
  4. using System.Collections;
  5. [InitializeOnLoad]
  6. public class RateStaticMeshCombiner : Editor
  7. {
  8. public static string namePackage;
  9. public static string rateUrl;
  10. public static float timer;
  11. static RateStaticMeshCombiner()
  12. {
  13. namePackage = "Static Mesh Combiner";
  14. rateUrl = "https://assetstore.unity.com/packages/tools/modeling/same-material-static-mesh-combiner-139565";
  15. timer = 300f;
  16. if (!EditorPrefs.GetBool("RateAsset_" + namePackage + "_bool"))
  17. EditorApplication.update += UpdateTime;
  18. }
  19. static void UpdateTime()
  20. {
  21. if (EditorPrefs.GetBool("RateAsset_" + namePackage + "_bool"))
  22. EditorApplication.update -= UpdateTime;
  23. if (timer < 0)
  24. {
  25. OpenWindow();
  26. EditorPrefs.SetBool("RateAsset_" + namePackage + "_bool", true);
  27. EditorApplication.update -= UpdateTime;
  28. }
  29. else
  30. timer -= 1 * Time.deltaTime;
  31. }
  32. static void OpenWindow()
  33. {
  34. int window = EditorUtility.DisplayDialogComplex(" " + namePackage + " | Leave a Rating?", "If you enjoy " + namePackage + " please take a moment to rate the asset.\n\nThank you for your support!", "Certainly!", "Never", "Cancel");
  35. switch (window)
  36. {
  37. case 0:
  38. Application.OpenURL(rateUrl);
  39. break;
  40. }
  41. EditorPrefs.SetBool("RateAsset_" + namePackage + "_bool", true);
  42. }
  43. }
  44. #endif