forked from cocos/cocos-engine
-
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.
deprecate
@property(cc.Texture2D) value = null;
in class defined by…
… using ES6 or TypeScript
- Loading branch information
Showing
7 changed files
with
115 additions
and
15 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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,82 @@ | ||
if (TestEditorExtends) { | ||
(function () { | ||
|
||
module('Migrating Raw Assets'); | ||
|
||
test('serialization if declared in the OLD way', function () { | ||
// setup | ||
var MyAsset = cc.Class({ | ||
name: 'MyAsset', | ||
properties: { | ||
ref_full: { | ||
url: cc.Texture2D, | ||
default: "", | ||
}, | ||
ref_brief: cc.Texture2D, | ||
} | ||
}); | ||
var asset = new MyAsset(); | ||
asset.ref_full = 'foo'; | ||
asset.ref_brief = 'foo'; | ||
|
||
// serialize | ||
var restore = Editor.Utils.UuidCache.urlToUuid; | ||
Editor.Utils.UuidCache.urlToUuid = function (url) { | ||
return { | ||
foo: '01', | ||
}[url]; | ||
}; | ||
var serializedAsset = Editor.serialize(asset); | ||
Editor.Utils.UuidCache.urlToUuid = restore; | ||
|
||
// deserialize | ||
var deserializedAsset = cc.deserialize(serializedAsset, null, {createAssetRefs: true}); | ||
|
||
// test | ||
ok(deserializedAsset.ref_full._uuid === '01', 'should support serialization if declared in full form'); | ||
ok(deserializedAsset.ref_brief._uuid === '01', 'should support serialization if declared in brief form'); | ||
|
||
//teardown | ||
cc.js.unregisterClass(MyAsset); | ||
}); | ||
|
||
test('serialization if declared in the NEW way', function () { | ||
// setup | ||
var MyAsset = cc.Class({ | ||
name: 'MyAsset', | ||
properties: { | ||
ref_full: { | ||
type: cc.Texture2D, | ||
default: null, | ||
}, | ||
// TODO - uncomment in 2.0 | ||
// ref_brief: cc.Texture2D, | ||
} | ||
}); | ||
var asset = new MyAsset(); | ||
asset.ref_full = new cc.Texture2D(); | ||
asset.ref_full._uuid = '01'; | ||
// asset.ref_brief = asset.ref_full; | ||
|
||
// serialize | ||
var restore = Editor.Utils.UuidCache.urlToUuid; | ||
Editor.Utils.UuidCache.urlToUuid = function (url) { | ||
return { | ||
foo: '01', | ||
}[url]; | ||
}; | ||
var serializedAsset = Editor.serialize(asset); | ||
Editor.Utils.UuidCache.urlToUuid = restore; | ||
|
||
// deserialize | ||
var deserializedAsset = cc.deserialize(serializedAsset, null, {createAssetRefs: true}); | ||
|
||
// test | ||
ok(deserializedAsset.ref_full._uuid === '01', 'should support serialization if declared in full form'); | ||
// ok(deserializedAsset.ref_brief._uuid === '01', 'should support serialization if declared in brief form'); | ||
|
||
//teardown | ||
cc.js.unregisterClass(MyAsset); | ||
}); | ||
})(); | ||
} |