ReporterEditor.cs 6.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. using UnityEngine;
  2. using UnityEditor;
  3. using UnityEditor.Callbacks;
  4. using System.IO;
  5. using System.Collections;
  6. public class ReporterEditor : Editor
  7. {
  8. [MenuItem("Reporter/Create")]
  9. public static void CreateReporter()
  10. {
  11. const int ReporterExecOrder = -12000;
  12. GameObject reporterObj = new GameObject();
  13. reporterObj.name = "Reporter";
  14. Reporter reporter = reporterObj.AddComponent<Reporter>();
  15. reporterObj.AddComponent<ReporterMessageReceiver>();
  16. //reporterObj.AddComponent<TestReporter>();
  17. // Register root object for undo.
  18. Undo.RegisterCreatedObjectUndo(reporterObj, "Create Reporter Object");
  19. MonoScript reporterScript = MonoScript.FromMonoBehaviour(reporter);
  20. string reporterPath = Path.GetDirectoryName(AssetDatabase.GetAssetPath(reporterScript));
  21. if (MonoImporter.GetExecutionOrder(reporterScript) != ReporterExecOrder) {
  22. MonoImporter.SetExecutionOrder(reporterScript, ReporterExecOrder);
  23. //Debug.Log("Fixing exec order for " + reporterScript.name);
  24. }
  25. reporter.images = new Images();
  26. reporter.images.clearImage = (Texture2D)AssetDatabase.LoadAssetAtPath(Path.Combine(reporterPath, "Images/clear.png"), typeof(Texture2D));
  27. reporter.images.collapseImage = (Texture2D)AssetDatabase.LoadAssetAtPath(Path.Combine(reporterPath, "Images/collapse.png"), typeof(Texture2D));
  28. reporter.images.clearOnNewSceneImage = (Texture2D)AssetDatabase.LoadAssetAtPath(Path.Combine(reporterPath, "Images/clearOnSceneLoaded.png"), typeof(Texture2D));
  29. reporter.images.showTimeImage = (Texture2D)AssetDatabase.LoadAssetAtPath(Path.Combine(reporterPath, "Images/timer_1.png"), typeof(Texture2D));
  30. reporter.images.showSceneImage = (Texture2D)AssetDatabase.LoadAssetAtPath(Path.Combine(reporterPath, "Images/UnityIcon.png"), typeof(Texture2D));
  31. reporter.images.userImage = (Texture2D)AssetDatabase.LoadAssetAtPath(Path.Combine(reporterPath, "Images/user.png"), typeof(Texture2D));
  32. reporter.images.showMemoryImage = (Texture2D)AssetDatabase.LoadAssetAtPath(Path.Combine(reporterPath, "Images/memory.png"), typeof(Texture2D));
  33. reporter.images.softwareImage = (Texture2D)AssetDatabase.LoadAssetAtPath(Path.Combine(reporterPath, "Images/software.png"), typeof(Texture2D));
  34. reporter.images.dateImage = (Texture2D)AssetDatabase.LoadAssetAtPath(Path.Combine(reporterPath, "Images/date.png"), typeof(Texture2D));
  35. reporter.images.showFpsImage = (Texture2D)AssetDatabase.LoadAssetAtPath(Path.Combine(reporterPath, "Images/fps.png"), typeof(Texture2D));
  36. //reporter.images.graphImage = (Texture2D)AssetDatabase.LoadAssetAtPath(Path.Combine(reporterPath, "Images/chart.png"), typeof(Texture2D));
  37. reporter.images.infoImage = (Texture2D)AssetDatabase.LoadAssetAtPath(Path.Combine(reporterPath, "Images/info.png"), typeof(Texture2D));
  38. reporter.images.saveLogsImage = (Texture2D)AssetDatabase.LoadAssetAtPath(Path.Combine(reporterPath, "Images/Save.png"), typeof(Texture2D));
  39. reporter.images.searchImage = (Texture2D)AssetDatabase.LoadAssetAtPath(Path.Combine(reporterPath, "Images/search.png"), typeof(Texture2D));
  40. reporter.images.copyImage = (Texture2D)AssetDatabase.LoadAssetAtPath(Path.Combine(reporterPath, "Images/copy.png"), typeof(Texture2D));
  41. reporter.images.closeImage = (Texture2D)AssetDatabase.LoadAssetAtPath(Path.Combine(reporterPath, "Images/close.png"), typeof(Texture2D));
  42. reporter.images.buildFromImage = (Texture2D)AssetDatabase.LoadAssetAtPath(Path.Combine(reporterPath, "Images/buildFrom.png"), typeof(Texture2D));
  43. reporter.images.systemInfoImage = (Texture2D)AssetDatabase.LoadAssetAtPath(Path.Combine(reporterPath, "Images/ComputerIcon.png"), typeof(Texture2D));
  44. reporter.images.graphicsInfoImage = (Texture2D)AssetDatabase.LoadAssetAtPath(Path.Combine(reporterPath, "Images/graphicCard.png"), typeof(Texture2D));
  45. reporter.images.backImage = (Texture2D)AssetDatabase.LoadAssetAtPath(Path.Combine(reporterPath, "Images/back.png"), typeof(Texture2D));
  46. reporter.images.logImage = (Texture2D)AssetDatabase.LoadAssetAtPath(Path.Combine(reporterPath, "Images/log_icon.png"), typeof(Texture2D));
  47. reporter.images.warningImage = (Texture2D)AssetDatabase.LoadAssetAtPath(Path.Combine(reporterPath, "Images/warning_icon.png"), typeof(Texture2D));
  48. reporter.images.errorImage = (Texture2D)AssetDatabase.LoadAssetAtPath(Path.Combine(reporterPath, "Images/error_icon.png"), typeof(Texture2D));
  49. reporter.images.barImage = (Texture2D)AssetDatabase.LoadAssetAtPath(Path.Combine(reporterPath, "Images/bar.png"), typeof(Texture2D));
  50. reporter.images.button_activeImage = (Texture2D)AssetDatabase.LoadAssetAtPath(Path.Combine(reporterPath, "Images/button_active.png"), typeof(Texture2D));
  51. reporter.images.even_logImage = (Texture2D)AssetDatabase.LoadAssetAtPath(Path.Combine(reporterPath, "Images/even_log.png"), typeof(Texture2D));
  52. reporter.images.odd_logImage = (Texture2D)AssetDatabase.LoadAssetAtPath(Path.Combine(reporterPath, "Images/odd_log.png"), typeof(Texture2D));
  53. reporter.images.selectedImage = (Texture2D)AssetDatabase.LoadAssetAtPath(Path.Combine(reporterPath, "Images/selected.png"), typeof(Texture2D));
  54. reporter.images.reporterScrollerSkin = (GUISkin)AssetDatabase.LoadAssetAtPath(Path.Combine(reporterPath, "Images/reporterScrollerSkin.guiskin"), typeof(GUISkin));
  55. }
  56. }
  57. public class ReporterModificationProcessor : UnityEditor.AssetModificationProcessor
  58. {
  59. [InitializeOnLoad]
  60. public class BuildInfo
  61. {
  62. static BuildInfo()
  63. {
  64. EditorApplication.update += Update;
  65. }
  66. static bool isCompiling = true;
  67. static void Update()
  68. {
  69. if (!EditorApplication.isCompiling && isCompiling) {
  70. //Debug.Log("Finish Compile");
  71. if (!Directory.Exists(Application.dataPath + "/StreamingAssets")) {
  72. Directory.CreateDirectory(Application.dataPath + "/StreamingAssets");
  73. }
  74. string info_path = Application.dataPath + "/StreamingAssets/build_info";
  75. StreamWriter build_info = new StreamWriter(info_path);
  76. build_info.Write("Build from " + SystemInfo.deviceName + " at " + System.DateTime.Now.ToString());
  77. build_info.Close();
  78. }
  79. isCompiling = EditorApplication.isCompiling;
  80. }
  81. }
  82. }