FilesCopy.cs 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. using UnityEditor;
  2. using UnityEngine;
  3. namespace CustomGame.Scripts.Editor
  4. {
  5. public class FilesCopy : EditorWindow
  6. {
  7. private string _fromPath;
  8. private string _toPath;
  9. private string _extension = ".cs";
  10. [MenuItem("Tools/Helper/Copy Files")]
  11. private static void ShowWindow()
  12. {
  13. var window = GetWindow<FilesCopy>();
  14. window.titleContent = new GUIContent("Copy Files");
  15. window.Show();
  16. }
  17. private void OnGUI()
  18. {
  19. _fromPath = EditorGUILayout.TextField("From Path", _fromPath);
  20. _toPath = EditorGUILayout.TextField("To Path", _toPath);
  21. _extension = EditorGUILayout.TextField("Extension", _extension);
  22. if (!GUILayout.Button("Copy")) return;
  23. var files = System.IO.Directory.GetFiles(_fromPath, $"*.{_extension}", System.IO.SearchOption.AllDirectories);
  24. foreach (var file in files)
  25. {
  26. System.IO.File.Copy(file, _toPath + "/" + System.IO.Path.GetFileName(file));
  27. }
  28. }
  29. }
  30. }