PreprocessorDefine.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. using System.Collections.Generic;
  2. using UnityEditor;
  3. namespace Mirror
  4. {
  5. static class PreprocessorDefine
  6. {
  7. /// <summary>
  8. /// Add define symbols as soon as Unity gets done compiling.
  9. /// </summary>
  10. [InitializeOnLoadMethod]
  11. public static void AddDefineSymbols()
  12. {
  13. string currentDefines = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);
  14. HashSet<string> defines = new HashSet<string>(currentDefines.Split(';'))
  15. {
  16. "MIRROR",
  17. "MIRROR_17_0_OR_NEWER",
  18. "MIRROR_18_0_OR_NEWER",
  19. "MIRROR_24_0_OR_NEWER",
  20. "MIRROR_26_0_OR_NEWER",
  21. "MIRROR_27_0_OR_NEWER",
  22. "MIRROR_28_0_OR_NEWER",
  23. "MIRROR_29_0_OR_NEWER",
  24. "MIRROR_30_0_OR_NEWER",
  25. "MIRROR_30_5_2_OR_NEWER",
  26. "MIRROR_32_1_2_OR_NEWER",
  27. "MIRROR_32_1_4_OR_NEWER",
  28. "MIRROR_35_0_OR_NEWER",
  29. "MIRROR_35_1_OR_NEWER",
  30. "MIRROR_37_0_OR_NEWER",
  31. "MIRROR_38_0_OR_NEWER",
  32. "MIRROR_39_0_OR_NEWER",
  33. "MIRROR_40_0_OR_NEWER",
  34. "MIRROR_41_0_OR_NEWER",
  35. "MIRROR_42_0_OR_NEWER",
  36. "MIRROR_43_0_OR_NEWER",
  37. "MIRROR_44_0_OR_NEWER",
  38. "MIRROR_46_0_OR_NEWER",
  39. "MIRROR_47_0_OR_NEWER",
  40. "MIRROR_53_0_OR_NEWER",
  41. "MIRROR_55_0_OR_NEWER",
  42. "MIRROR_57_0_OR_NEWER",
  43. "MIRROR_58_0_OR_NEWER",
  44. "MIRROR_65_0_OR_NEWER",
  45. "MIRROR_66_0_OR_NEWER",
  46. "MIRROR_2022_9_OR_NEWER",
  47. "MIRROR_2022_10_OR_NEWER",
  48. };
  49. // only touch PlayerSettings if we actually modified it.
  50. // otherwise it shows up as changed in git each time.
  51. string newDefines = string.Join(";", defines);
  52. if (newDefines != currentDefines)
  53. {
  54. PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, newDefines);
  55. }
  56. }
  57. }
  58. }