-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: Copy several files to destination directory (optionally) #34
base: master
Are you sure you want to change the base?
Feat: Copy several files to destination directory (optionally) #34
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution!
Please, do not remove the previous step Editor/IO/Files/CopyFileToDirectory.cs, as it can break already created pipelines. Create a new step
{ | ||
[SerializeField] private PathProperty[] m_filePaths = default; | ||
[System.Obsolete, HideInInspector] | ||
[SerializeField] private PathProperty m_filePath = default; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like can be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. Since we won't be replacing CopyFileToDirectory, we don't need to replicate its properties.
)] | ||
public sealed class CopyFilesToDirectory : BuildStep | ||
{ | ||
[SerializeField] private PathProperty[] m_filePaths = default; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can name it m_sourceDirectory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I will add a property for source directory. It may simplify using this build step. However I will also rename this to m_sourceFiles
for clarity.
[SerializeField] private PathProperty m_filePath = default; | ||
[SerializeField] private PathProperty m_destination = default; | ||
|
||
public override async Task Execute() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check is the m_sourceDirectory path is a directory path. If not - throw an exception
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. I will make sure m_destinationDirectory
is a directory path.
OK. Looking back at this commit, I overcomplicated adding this BuildStep and that led to other extra lines and methods. It looks like I deliberately gave the new step the same meta file and guid as the previous CopyFileToDirectory because (at least at the time) Unity used the guid to identify ScriptableObject instances. I'm not sure if this step would have been sufficient to prevent old piplelines from breaking. I likely tested it only on my own pipleline. I'll refactor to not remove the existing step. |
This changes the CopyFileToDirectory BuildStep to a CopyFilesToDirectory BuildStep. The OnValidate method is included to copy the
m_filePath
property from existing CopyFileToDirectory scriptable objects into them_filePaths
property.