Merge pull request #1719 from rschamp/hotfix/sprite-upload-from-image
Handle images uploaded as sprites
This commit is contained in:
2 files changed
+16
-1
No files matched your search
@@ -71,7 +71,19 @@ const deserializeCostume = function (costume, runtime, zip, assetFileName) {
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
if (!zip) { // Zip will not be provided if loading project json from server
|
||||
if (costume.asset) {
|
||||
// When uploading a sprite from an image file, the asset data will be provided
|
||||
// @todo Cache the asset data somewhere and pull it out here
|
||||
return Promise.resolve(storage.createAsset(
|
||||
costume.asset.assetType,
|
||||
costume.asset.dataFormat,
|
||||
new Uint8Array(Object.keys(costume.asset.data).map(key => costume.asset.data[key])),
|
||||
costume.asset.assetId
|
||||
));
|
||||
}
|
||||
|
||||
if (!zip) {
|
||||
// Zip will not be provided if loading project json from server
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
|
||||
@@ -823,6 +823,9 @@ const parseScratchObject = function (object, runtime, extensions, zip) {
|
||||
const costumePromises = (object.costumes || []).map(costumeSource => {
|
||||
// @todo: Make sure all the relevant metadata is being pulled out.
|
||||
const costume = {
|
||||
// costumeSource only has an asset if an image is being uploaded as
|
||||
// a sprite
|
||||
asset: costumeSource.asset,
|
||||
assetId: costumeSource.assetId,
|
||||
skinId: null,
|
||||
name: costumeSource.name,
|
||||
|
||||
Reference in new issue
Block a user