ConflictWatcher.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // using System;
  2. // using System.Collections.Generic;
  3. // using System.IO;
  4. // using UnityEditor;
  5. // using UnityEngine;
  6. //
  7. // namespace GitMerge
  8. // {
  9. // public class ConflictWatcher
  10. // {
  11. // private static FileSystemWatcher watcher;
  12. // private static FileSystemEventArgs e;
  13. //
  14. // public ConflictWatcher()
  15. // {
  16. // string assetPath = Application.dataPath;
  17. // watcher = new FileSystemWatcher(assetPath);
  18. // watcher.IncludeSubdirectories = true;
  19. // watcher.NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.FileName;
  20. // watcher.Changed += OnFileChanged;
  21. // watcher.EnableRaisingEvents = true;
  22. // }
  23. //
  24. // public event Action<string> OnConflict;
  25. //
  26. // private void OnFileChanged(object sender, FileSystemEventArgs _e)
  27. // {
  28. // e = _e;
  29. // EditorApplication.update += CheckWindow;
  30. // }
  31. //
  32. // private void CheckWindow()
  33. // {
  34. // AssetDatabase.Refresh();
  35. // EditorApplication.update -= CheckWindow;
  36. // var path = e.FullPath;
  37. // var relativePath = "Assets" + path.Substring(Application.dataPath.Length);
  38. //
  39. // if (!path.EndsWith(".unity") && !path.EndsWith(".prefab")) return;
  40. // // Found it
  41. // UnityEngine.Object asset;
  42. // try
  43. // {
  44. // asset = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(relativePath);
  45. // }
  46. // catch (Exception exception)
  47. // {
  48. // Debug.Log(exception);
  49. // throw;
  50. // }
  51. // Debug.Log("asset" + asset);
  52. // if (asset != null)
  53. // {
  54. // Debug.Log("Found asset" + asset.GetType());
  55. // bool isBroken = asset is BrokenPrefabAsset;
  56. //
  57. // // Open merge conflict window
  58. // if (isBroken)
  59. // {
  60. // OnConflict?.Invoke(relativePath);
  61. // }
  62. // }
  63. // }
  64. //
  65. // static bool IsOpenForEdit(string[] paths, List<string> outNotEditablePaths, StatusQueryOptions statusQueryOptions)
  66. // {
  67. // Debug.Log("IsOpenForEdit:");
  68. // // TODO: Do locking/unlocking here
  69. //
  70. // foreach (var path in paths)
  71. // {
  72. // // Check for lock
  73. // Debug.Log(path);
  74. // }
  75. // return true;
  76. // }
  77. // }
  78. // }