Skip to content

Commit

Permalink
Feat: Copy several files to destination directory (optionally)
Browse files Browse the repository at this point in the history
  • Loading branch information
MoxieWhimsy committed May 10, 2023
1 parent 5cd15c8 commit 855e115
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 27 deletions.
27 changes: 0 additions & 27 deletions Editor/IO/Files/CopyFileToDirectory.cs

This file was deleted.

40 changes: 40 additions & 0 deletions Editor/IO/Files/CopyFilesToDirectory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System.IO;
using System.Threading.Tasks;
using UnityEditor;
using UnityEngine;

namespace UniTools.Build
{
[CreateAssetMenu(
fileName = nameof(CopyFilesToDirectory),
menuName = MenuPaths.IO + nameof(CopyFilesToDirectory)
)]
public sealed class CopyFilesToDirectory : BuildStep
{
[SerializeField] private PathProperty[] m_filePaths = default;
[System.Obsolete, HideInInspector]
[SerializeField] private PathProperty m_filePath = default;
[SerializeField] private PathProperty m_destination = default;

public override async Task Execute()
{
foreach (var filePath in m_filePaths)
{
string fileName = Path.GetFileName(filePath.ToString());
string dest = Path.Combine(m_destination.ToString(), fileName);
FileUtil.DeleteFileOrDirectory(dest);
FileUtil.CopyFileOrDirectory(filePath.ToString(), dest);
}

await Task.CompletedTask;
}

private void OnValidate()
{
if (m_filePaths.Length == 0 && !string.IsNullOrEmpty(m_filePath.ToString()))
{
m_filePaths = new[] { m_filePath };
}
}
}
}
File renamed without changes.

0 comments on commit 855e115

Please sign in to comment.