ServerCommandLineEditor.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. using System;
  2. using System.IO;
  3. using System.Linq;
  4. using UnityEditor;
  5. using UnityEngine;
  6. namespace ET
  7. {
  8. public enum DevelopMode
  9. {
  10. 正式 = 0,
  11. 开发 = 1,
  12. 压测 = 2,
  13. }
  14. public class ServerCommandLineEditor: EditorWindow
  15. {
  16. [MenuItem("ET/ServerTools")]
  17. public static void ShowWindow()
  18. {
  19. GetWindow<ServerCommandLineEditor>(DockDefine.Types);
  20. }
  21. private int selectStartConfigIndex = 1;
  22. private string[] startConfigs;
  23. private string startConfig;
  24. private DevelopMode developMode;
  25. public void OnEnable()
  26. {
  27. DirectoryInfo directoryInfo = new DirectoryInfo("../Config/GenFromExcel/s/StartConfig");
  28. this.startConfigs = directoryInfo.GetDirectories().Select(x => x.Name).ToArray();
  29. }
  30. public void OnGUI()
  31. {
  32. selectStartConfigIndex = EditorGUILayout.Popup(selectStartConfigIndex, this.startConfigs);
  33. this.startConfig = this.startConfigs[this.selectStartConfigIndex];
  34. this.developMode = (DevelopMode) EditorGUILayout.EnumPopup("起服模式:", this.developMode);
  35. string dotnet = "dotnet.exe";
  36. #if UNITY_EDITOR_OSX
  37. dotnet = "dotnet";
  38. #endif
  39. if (GUILayout.Button("Start Server(Single Process)"))
  40. {
  41. string arguments = $"App.dll --Process=1 --StartConfig=StartConfig/{this.startConfig} --Console=1";
  42. ProcessHelper.Run(dotnet, arguments, "../Bin/");
  43. }
  44. if (GUILayout.Button("Start Watcher"))
  45. {
  46. string arguments = $"App.dll --AppType=Watcher --StartConfig=StartConfig/{this.startConfig} --Console=1";
  47. ProcessHelper.Run(dotnet, arguments, "../Bin/");
  48. }
  49. if (GUILayout.Button("Start Mongo"))
  50. {
  51. ProcessHelper.Run("mongod", @"--dbpath=db", "../Database/bin/");
  52. }
  53. }
  54. }
  55. }