support copy/pasting assets between projects #10383
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
fixes microsoft/pxt-arcade#6656
this changes the asset fields' serialization so that they also include any referenced assets when saving state. saveState/loadState aren't called on fields during XML serialization, but they are called during copy/paste so this handles that scenario nicely without changing the save format of our projects.
when loading the state of a saved asset, there are a few scenarios to consider:
for scenario 1, we simply create a new asset in the destination project. for scenario 2, we don't do anything since the asset is already in project.
scenario 3 is the tricky one. first we check to see if there is another asset in the destination project with the same value. if so, paste that one instead. if there isn't, then we need to create a new asset with a different id to avoid the collision. luckily, we already have code to do this for tilemaps since we have supported copying/pasting from within the tilemap editor for a while now