PreprocessorDefine.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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_57_0_OR_NEWER",
  18. "MIRROR_58_0_OR_NEWER",
  19. "MIRROR_65_0_OR_NEWER",
  20. "MIRROR_66_0_OR_NEWER",
  21. "MIRROR_2022_9_OR_NEWER",
  22. "MIRROR_2022_10_OR_NEWER",
  23. "MIRROR_70_0_OR_NEWER",
  24. "MIRROR_71_0_OR_NEWER",
  25. "MIRROR_73_OR_NEWER",
  26. "MIRROR_78_OR_NEWER",
  27. "MIRROR_79_OR_NEWER",
  28. "MIRROR_81_OR_NEWER"
  29. // Remove oldest when adding next month's symbol.
  30. // Keep a rolling 12 months of symbols.
  31. };
  32. // only touch PlayerSettings if we actually modified it,
  33. // otherwise it shows up as changed in git each time.
  34. string newDefines = string.Join(";", defines);
  35. if (newDefines != currentDefines)
  36. {
  37. PlayerSettings.SetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup, newDefines);
  38. }
  39. }
  40. }
  41. }