forked from UniToolsTeam/unitools-build
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Copy several files to destination directory (optionally)
- Loading branch information
1 parent
5cd15c8
commit 855e115
Showing
3 changed files
with
40 additions
and
27 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.