Commit 566cd0c0 authored by 李维's avatar 李维

测试

parent bd21a152
No preview for this file type
{ {
"ver": "1.1.2", "ver": "1.1.2",
"uuid": "37accd6c-0060-4a91-81cd-1b535550f8e1", "uuid": "c35bb2f6-f24a-4850-ae44-643f2fdc7541",
"isBundle": true, "isBundle": false,
"bundleName": "", "bundleName": "",
"priority": 1, "priority": 1,
"compressionType": {}, "compressionType": {},
"optimizeHotUpdate": {}, "optimizeHotUpdate": {},
"inlineSpriteFrames": {}, "inlineSpriteFrames": {},
"isRemoteBundle": { "isRemoteBundle": {
"ios": true, "ios": false,
"android": true "android": false
}, },
"subMetas": {} "subMetas": {}
} }
\ No newline at end of file
{ {
"ver": "1.1.2", "ver": "1.1.2",
"uuid": "6927db8f-12a4-4b92-b80d-81b6c0739893", "uuid": "cb9fa4ea-66ca-45af-ad31-e445c7b0ef32",
"isBundle": false, "isBundle": false,
"bundleName": "", "bundleName": "",
"priority": 1, "priority": 1,
......
{ {
"ver": "2.0.1", "ver": "2.0.1",
"uuid": "c8749a73-870c-4d16-822b-b239a8df01d9", "uuid": "f0680ae0-c079-45ef-abd7-9e63d90b982b",
"downloadMode": 0, "downloadMode": 0,
"duration": 0.130612, "duration": 0.130612,
"subMetas": {} "subMetas": {}
......
{ {
"ver": "1.1.2", "ver": "1.1.2",
"uuid": "dcb19a12-3740-4da4-bb1e-031290059858", "uuid": "0853721c-3f55-4eb2-873d-e3081cfadd4b",
"isBundle": false, "isBundle": false,
"bundleName": "", "bundleName": "",
"priority": 1, "priority": 1,
......
{ {
"ver": "1.1.2", "ver": "1.1.2",
"uuid": "46c7a43b-b19d-4d4c-992b-0f3c0b39bd0e", "uuid": "20185448-a1ca-4de2-8b37-7bf6cdfccbae",
"isBundle": false, "isBundle": false,
"bundleName": "", "bundleName": "",
"priority": 1, "priority": 1,
......
{ {
"ver": "1.1.0", "ver": "1.1.0",
"uuid": "d129bde1-7a86-4690-8685-790edcd78e56", "uuid": "c551970e-b095-45f3-9f1d-25cde8b8deb1",
"subMetas": {} "subMetas": {}
} }
\ No newline at end of file
{ {
"ver": "1.1.2", "ver": "1.1.2",
"uuid": "22d21a96-1507-41bb-a42d-6e8f9c77567e", "uuid": "e8bd16b0-3804-45a9-a8ca-f52c02224f55",
"isBundle": false, "isBundle": false,
"bundleName": "", "bundleName": "",
"priority": 1, "priority": 1,
......
// Learn cc.Class:
// - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
cc.Class({
extends: cc.Component,
properties: {
// foo: {
// // ATTRIBUTES:
// default: null, // The default value will be used only when the component attaching
// // to a node for the first time
// type: cc.SpriteFrame, // optional, default is typeof default
// serializable: true, // optional, default is true
// },
// bar: {
// get () {
// return this._bar;
// },
// set (value) {
// this._bar = value;
// }
// },
},
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
obj: null,
start () {
this.obj = {a: 1, b: ()=>{console.log("1")},c:[1,1,1]};
console.log("========== liwei_test_001 ==========");
console.log(this.obj.a);
this.obj.b()
console.log(this.obj.c);
console.log("========== liwei_test_001 ==========");
},
// update (dt) {},
});
{
"ver": "1.0.8",
"uuid": "1cc98882-6ac2-45bc-97ec-38ceeac9d774",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
"_groupIndex": 0, "_groupIndex": 0,
"groupIndex": 0, "groupIndex": 0,
"autoReleaseAssets": true, "autoReleaseAssets": true,
"_id": "76bcad6c-e132-49f4-81c8-7590d4c053b8" "_id": "0737ce42-24f0-45c6-8e1a-8bdab4f74ba3"
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
...@@ -79,21 +79,21 @@ ...@@ -79,21 +79,21 @@
}, },
{ {
"__id__": 14 "__id__": 14
},
{
"__id__": 24
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 24 "__id__": 27
},
{
"__id__": 25
}, },
{ {
"__id__": 26 "__id__": 28
}, },
{ {
"__id__": 27 "__id__": 29
} }
], ],
"_prefab": null, "_prefab": null,
...@@ -320,7 +320,7 @@ ...@@ -320,7 +320,7 @@
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_spriteFrame": { "_spriteFrame": {
"__uuid__": "09c66b1f-c4ed-47e4-8724-086f3abf2ce9" "__uuid__": "8288e3d4-4c75-4b27-8f01-f7014417f4dd"
}, },
"_type": 0, "_type": 0,
"_sizeMode": 1, "_sizeMode": 1,
...@@ -482,7 +482,7 @@ ...@@ -482,7 +482,7 @@
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_spriteFrame": { "_spriteFrame": {
"__uuid__": "59b81c11-a9f3-4b40-b00a-372e8bcf8053" "__uuid__": "ce19457d-e8f3-4c38-ae3e-d4b99208ddb5"
}, },
"_type": 0, "_type": 0,
"_sizeMode": 1, "_sizeMode": 1,
...@@ -647,7 +647,7 @@ ...@@ -647,7 +647,7 @@
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_spriteFrame": { "_spriteFrame": {
"__uuid__": "05ec9c3c-62ba-40c1-a62f-62fb4a7bdc90" "__uuid__": "e5a2dbaa-a677-4a32-90d7-a1b057d7fb59"
}, },
"_type": 0, "_type": 0,
"_sizeMode": 1, "_sizeMode": 1,
...@@ -940,7 +940,7 @@ ...@@ -940,7 +940,7 @@
"_lineHeight": 40, "_lineHeight": 40,
"_enableWrapText": true, "_enableWrapText": true,
"_N$file": { "_N$file": {
"__uuid__": "d129bde1-7a86-4690-8685-790edcd78e56" "__uuid__": "c551970e-b095-45f3-9f1d-25cde8b8deb1"
}, },
"_isSystemFontUsed": false, "_isSystemFontUsed": false,
"_spacingX": 0, "_spacingX": 0,
...@@ -1090,7 +1090,7 @@ ...@@ -1090,7 +1090,7 @@
"_srcBlendFactor": 770, "_srcBlendFactor": 770,
"_dstBlendFactor": 771, "_dstBlendFactor": 771,
"_spriteFrame": { "_spriteFrame": {
"__uuid__": "3a8ab6be-307e-441c-a6c9-94daea1a62ba" "__uuid__": "6fbc30a8-3c49-44ae-8ba4-7f56f385b78a"
}, },
"_type": 0, "_type": 0,
"_sizeMode": 1, "_sizeMode": 1,
...@@ -1239,7 +1239,7 @@ ...@@ -1239,7 +1239,7 @@
}, },
"_enabled": true, "_enabled": true,
"_clip": { "_clip": {
"__uuid__": "c8749a73-870c-4d16-822b-b239a8df01d9" "__uuid__": "f0680ae0-c079-45ef-abd7-9e63d90b982b"
}, },
"_volume": 1, "_volume": 1,
"_mute": false, "_mute": false,
...@@ -1249,6 +1249,131 @@ ...@@ -1249,6 +1249,131 @@
"preload": false, "preload": false,
"_id": "dey05oKrBIspvsDa6pOIQz" "_id": "dey05oKrBIspvsDa6pOIQz"
}, },
{
"__type__": "cc.Node",
"_name": "New Label",
"_objFlags": 0,
"_parent": {
"__id__": 2
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 25
},
{
"__id__": 26
}
],
"_prefab": null,
"_opacity": 255,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_contentSize": {
"__type__": "cc.Size",
"width": 153.42,
"height": 50.4
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_trs": {
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0,
284.8,
0,
0,
0,
0,
1,
1,
1,
1
]
},
"_eulerAngles": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_skewX": 0,
"_skewY": 0,
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "35/ORAdXVHeaNw1xQEekHm"
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 24
},
"_enabled": true,
"_materials": [
{
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
],
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_string": "Test-001",
"_N$string": "Test-001",
"_fontSize": 40,
"_lineHeight": 40,
"_enableWrapText": true,
"_N$file": null,
"_isSystemFontUsed": true,
"_spacingX": 0,
"_batchAsBitmap": false,
"_styleFlags": 0,
"_underlineHeight": 0,
"_N$horizontalAlign": 1,
"_N$verticalAlign": 1,
"_N$fontFamily": "Arial",
"_N$overflow": 0,
"_N$cacheMode": 0,
"_id": "6buSQp+2pA55KDrGZX6GqJ"
},
{
"__type__": "cc.Widget",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 24
},
"_enabled": true,
"alignMode": 1,
"_target": null,
"_alignFlags": 17,
"_left": 0,
"_right": 0,
"_top": 50,
"_bottom": 0,
"_verticalCenter": 0,
"_horizontalCenter": 0,
"_isAbsLeft": true,
"_isAbsRight": true,
"_isAbsTop": true,
"_isAbsBottom": true,
"_isAbsHorizontalCenter": true,
"_isAbsVerticalCenter": true,
"_originalWidth": 0,
"_originalHeight": 0,
"_id": "53qUN1VP5HDqxlHvQU+Gly"
},
{ {
"__type__": "cc.Canvas", "__type__": "cc.Canvas",
"_name": "", "_name": "",
...@@ -1294,7 +1419,7 @@ ...@@ -1294,7 +1419,7 @@
"_id": "29zXboiXFBKoIV4PQ2liTe" "_id": "29zXboiXFBKoIV4PQ2liTe"
}, },
{ {
"__type__": "858c95E7DxIQ7GL8/wXm5YL", "__type__": "408a6f4ZfpM8Yzyg+IOGg/V",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
...@@ -1302,15 +1427,5 @@ ...@@ -1302,15 +1427,5 @@
}, },
"_enabled": true, "_enabled": true,
"_id": "eaTVUpqahPfZeO9+sUI7RP" "_id": "eaTVUpqahPfZeO9+sUI7RP"
},
{
"__type__": "1cc98iCasJFvJfsOM7qydd0",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 2
},
"_enabled": true,
"_id": "35BCVKp6RAUJZl/09oC1Tq"
} }
] ]
\ No newline at end of file
{ {
"ver": "1.2.9", "ver": "1.2.9",
"uuid": "bde7b96c-d33d-429d-8c6b-ae0af1a8d62b", "uuid": "0737ce42-24f0-45c6-8e1a-8bdab4f74ba3",
"asyncLoadAssets": false, "asyncLoadAssets": false,
"autoReleaseAssets": true, "autoReleaseAssets": true,
"subMetas": {} "subMetas": {}
......
import { asyncDelay, onHomeworkFinish } from "../script/util"; import { asyncDelay, onHomeworkFinish } from "../script/util";
import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent"; import { MyCocosSceneComponent } from "../script/MyCocosSceneComponent";
import { testJS } from '../script/liwei_test_script'
const { ccclass, property } = cc._decorator; const { ccclass, property } = cc._decorator;
@ccclass @ccclass
...@@ -35,7 +35,6 @@ export default class SceneComponent extends MyCocosSceneComponent { ...@@ -35,7 +35,6 @@ export default class SceneComponent extends MyCocosSceneComponent {
} }
initView() { initView() {
testJS();
this.initBg(); this.initBg();
this.initPic(); this.initPic();
this.initBtn(); this.initBtn();
......
{ {
"ver": "1.0.8", "ver": "1.0.8",
"uuid": "858c9e44-ec3c-4843-b18b-f3fc179b960b", "uuid": "408a67f8-65fa-4cf1-8cf2-83e20e1a0fd5",
"isPlugin": false, "isPlugin": false,
"loadPluginInWeb": true, "loadPluginInWeb": true,
"loadPluginInNative": true, "loadPluginInNative": true,
......
{ {
"ver": "1.1.2", "ver": "1.1.2",
"uuid": "7fc99075-3b3b-4204-bdac-6837b65b349d", "uuid": "b0c008bc-cf92-463b-8360-0984e13c2e4d",
"isBundle": false, "isBundle": false,
"bundleName": "", "bundleName": "",
"priority": 1, "priority": 1,
......
{ {
"ver": "1.0.8", "ver": "1.0.8",
"uuid": "090f53c7-81c5-42fc-9bee-343164b8f6b1", "uuid": "f8b451ff-857c-4ca8-9870-866bc5154a29",
"isPlugin": false, "isPlugin": false,
"loadPluginInWeb": true, "loadPluginInWeb": true,
"loadPluginInNative": true, "loadPluginInNative": true,
......
export const defaultData = { export const defaultData = {
"pic_url": "http://staging-teach.cdn.ireadabc.com/ed94332a503c31e0908bd4c6923a2665.png", "pic_url": "http://staging-teach.cdn.ireadabc.com/ed94332a503c31e0908bd4c6923a2665.png",
"pic_url_2": "http://staging-teach.cdn.ireadabc.com/5fb60317ade0195d35ad8034d5370a7f.png", "pic_url_2": "http://staging-teach.cdn.ireadabc.com/5fb60317ade0195d35ad8034d5370a7f.png",
"text": "This is a test 001.", "text": "This is a test label-001.",
"audio_url": "http://staging-teach.cdn.ireadabc.com/f47f1d7b5c160fe1c59500d180346240.mp3" "audio_url": "http://staging-teach.cdn.ireadabc.com/f47f1d7b5c160fe1c59500d180346240.mp3"
} }
\ No newline at end of file
{ {
"ver": "1.0.8", "ver": "1.0.8",
"uuid": "1f8206fb-3413-4817-be4d-9adb7d4e0ee8", "uuid": "c41b0e51-55d7-443c-af3a-b22c3dd9b9e5",
"isPlugin": false, "isPlugin": false,
"loadPluginInWeb": true, "loadPluginInWeb": true,
"loadPluginInNative": true, "loadPluginInNative": true,
......
export function testJS() {
const obj = {a: 1, b: ()=>{console.log("1")},c:[1,1,1]};
console.log("========== liwei_test-01 ==========");
console.log(obj.a);
obj.b()
console.log(obj.c);
console.log("========== liwei_test-01 ==========");
}
\ No newline at end of file
{
"ver": "1.0.8",
"uuid": "314d036c-b824-4b4f-b0cb-83a39510db2e",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
{ {
"ver": "1.0.8", "ver": "1.0.8",
"uuid": "58d81fe3-4f52-4213-8872-834f4d22458b", "uuid": "b54300af-b8e5-4b4e-aa2f-9ac1cef7b598",
"isPlugin": true, "isPlugin": true,
"loadPluginInWeb": true, "loadPluginInWeb": true,
"loadPluginInNative": true, "loadPluginInNative": true,
......
{ {
"ver": "1.0.8", "ver": "1.0.8",
"uuid": "a81b1f6f-85b4-4c1c-83ea-74ba1fd6e17a", "uuid": "ade7af40-d56d-4087-bbc6-2888fef55353",
"isPlugin": false, "isPlugin": false,
"loadPluginInWeb": true, "loadPluginInWeb": true,
"loadPluginInNative": true, "loadPluginInNative": true,
......
{ {
"ver": "1.1.2", "ver": "1.1.2",
"uuid": "03f94607-cd21-464c-973e-1c509d0c35f8", "uuid": "8ba21262-178f-4fa5-afc9-2c1dd50ba3ab",
"isBundle": false, "isBundle": false,
"bundleName": "", "bundleName": "",
"priority": 1, "priority": 1,
......
{ {
"ver": "2.3.5", "ver": "2.3.5",
"uuid": "2fb8cf44-efcd-46c7-90fd-3f23a7a742c2", "uuid": "efa5fa09-a4dd-4bfc-ab7e-17c19f85408f",
"type": "sprite", "type": "sprite",
"wrapMode": "clamp", "wrapMode": "clamp",
"filterMode": "bilinear", "filterMode": "bilinear",
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
"subMetas": { "subMetas": {
"1orange": { "1orange": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "f296f100-5645-414b-8490-ba63d732d600", "uuid": "43d1e79d-6de8-4dcb-b8ce-d767df7913aa",
"rawTextureUuid": "2fb8cf44-efcd-46c7-90fd-3f23a7a742c2", "rawTextureUuid": "efa5fa09-a4dd-4bfc-ab7e-17c19f85408f",
"trimType": "auto", "trimType": "auto",
"trimThreshold": 1, "trimThreshold": 1,
"rotated": false, "rotated": false,
......
{ {
"ver": "2.3.5", "ver": "2.3.5",
"uuid": "82ad5851-aa98-4511-8094-ea297eabb201", "uuid": "e1b4d971-9876-4832-803a-5a321964a78b",
"type": "sprite", "type": "sprite",
"wrapMode": "clamp", "wrapMode": "clamp",
"filterMode": "bilinear", "filterMode": "bilinear",
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
"subMetas": { "subMetas": {
"bg": { "bg": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "09c66b1f-c4ed-47e4-8724-086f3abf2ce9", "uuid": "8288e3d4-4c75-4b27-8f01-f7014417f4dd",
"rawTextureUuid": "82ad5851-aa98-4511-8094-ea297eabb201", "rawTextureUuid": "e1b4d971-9876-4832-803a-5a321964a78b",
"trimType": "auto", "trimType": "auto",
"trimThreshold": 1, "trimThreshold": 1,
"rotated": false, "rotated": false,
......
{ {
"ver": "2.3.5", "ver": "2.3.5",
"uuid": "e7b4cd35-d6ba-4962-b09a-9c4a56b64472", "uuid": "9a79969a-0506-48d4-bc98-3c05d109b027",
"type": "sprite", "type": "sprite",
"wrapMode": "clamp", "wrapMode": "clamp",
"filterMode": "bilinear", "filterMode": "bilinear",
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
"subMetas": { "subMetas": {
"btn_left": { "btn_left": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "59b81c11-a9f3-4b40-b00a-372e8bcf8053", "uuid": "ce19457d-e8f3-4c38-ae3e-d4b99208ddb5",
"rawTextureUuid": "e7b4cd35-d6ba-4962-b09a-9c4a56b64472", "rawTextureUuid": "9a79969a-0506-48d4-bc98-3c05d109b027",
"trimType": "auto", "trimType": "auto",
"trimThreshold": 1, "trimThreshold": 1,
"rotated": false, "rotated": false,
......
{ {
"ver": "2.3.5", "ver": "2.3.5",
"uuid": "8cf9c5c5-8104-4dca-a73b-db2f608a3c77", "uuid": "d582359e-924e-4ee9-9964-1fc4bb417e71",
"type": "sprite", "type": "sprite",
"wrapMode": "clamp", "wrapMode": "clamp",
"filterMode": "bilinear", "filterMode": "bilinear",
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
"subMetas": { "subMetas": {
"btn_right": { "btn_right": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "05ec9c3c-62ba-40c1-a62f-62fb4a7bdc90", "uuid": "e5a2dbaa-a677-4a32-90d7-a1b057d7fb59",
"rawTextureUuid": "8cf9c5c5-8104-4dca-a73b-db2f608a3c77", "rawTextureUuid": "d582359e-924e-4ee9-9964-1fc4bb417e71",
"trimType": "auto", "trimType": "auto",
"trimThreshold": 1, "trimThreshold": 1,
"rotated": false, "rotated": false,
......
{ {
"ver": "2.3.5", "ver": "2.3.5",
"uuid": "542dfdf1-97af-4a73-914e-e314495084ec", "uuid": "18d07592-51a9-421e-8972-0f67b68d29e1",
"type": "sprite", "type": "sprite",
"wrapMode": "clamp", "wrapMode": "clamp",
"filterMode": "bilinear", "filterMode": "bilinear",
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
"subMetas": { "subMetas": {
"icon": { "icon": {
"ver": "1.0.4", "ver": "1.0.4",
"uuid": "3a8ab6be-307e-441c-a6c9-94daea1a62ba", "uuid": "6fbc30a8-3c49-44ae-8ba4-7f56f385b78a",
"rawTextureUuid": "542dfdf1-97af-4a73-914e-e314495084ec", "rawTextureUuid": "18d07592-51a9-421e-8972-0f67b68d29e1",
"trimType": "auto", "trimType": "auto",
"trimThreshold": 1, "trimThreshold": 1,
"rotated": false, "rotated": false,
......
var fs = require('fs-extra');
var file = require('./util/file');
module.exports = {
load() {
},
unload() {
},
replaceDirUuid: function (path, dbpath) {
Editor.log('开始处理:' + path);
file.findDirUuid(path);
file.replaceDirUuid(path);
Editor.log('开始刷新:' + dbpath);
Editor.assetdb.refresh(dbpath, function (err, results) {
Editor.log('资源刷新完成, 请重新打开该项目工程!');
});
},
messages: {
'replace'() {
var uuids = Editor.Selection.curSelection('asset');
uuids.forEach((uuid) => {
var dir_path = Editor.assetdb._uuid2path[uuid];
if (fs.existsSync(dir_path)) {
this.replaceDirUuid(dir_path, Editor.assetdb.uuidToUrl(uuid));
}
});
},
'replace-path': function (event, dir_path, refresh_path) {
if (fs.existsSync(dir_path)) {
this.replaceDirUuid(dir_path, refresh_path); // Editor.assetdb.fspathToUrl(refresh_path)
if (event.reply) {
event.reply(null, null);
}
}
},
},
}
\ No newline at end of file
{
"name": "replace-uuid",
"version": "0.0.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"version": "0.0.1",
"dependencies": {
"node-uuid": "1.4.8"
}
},
"node_modules/node-uuid": {
"version": "1.4.8",
"resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.8.tgz",
"integrity": "sha1-sEDrCSOWivq/jTL7HxfxFn/auQc=",
"deprecated": "Use uuid module instead",
"bin": {
"uuid": "bin/uuid"
}
}
},
"dependencies": {
"node-uuid": {
"version": "1.4.8",
"resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.8.tgz",
"integrity": "sha1-sEDrCSOWivq/jTL7HxfxFn/auQc="
}
}
}
{
"name": "replace-uuid",
"version": "0.0.1",
"description": "replace-uuid",
"author": "Cocos Creator",
"main": "main.js",
"main-menu": {
"i18n:MAIN_MENU.package.title/replace-uuid": {
"message": "replace-uuid:replace"
}
},
"dependencies": {
"node-uuid": "1.4.8"
}
}
/**
* 一、建立目录中所有meta文件中uuid和新生成uuid的映射关系
* 二、替换目录中指定类型文件中的uuid成新的uuid
*/
var fs = require("fs-extra");
var path = require("path");
var uuidUtils = require("./uuidUtils");
var uuidMap = {};
var Reg_Uuid = /^[0-9a-fA-F-]{36}$/;
module.exports = {
/**
* 递归目录找到所有meta文件的uuid
* 参考 https://docs.cocos.com/creator/manual/zh/advanced-topics/meta.html
*/
findDirUuid: function (dir) {
var stat = fs.statSync(dir);
if (!stat.isDirectory()) {
return;
}
var subpaths = fs.readdirSync(dir),
subpath;
for (var i = 0; i < subpaths.length; ++i) {
if (subpaths[i][0] === ".") {
continue;
}
subpath = path.join(dir, subpaths[i]);
stat = fs.statSync(subpath);
if (stat.isDirectory()) {
this.findDirUuid(subpath);
} else if (stat.isFile()) {
var metastr = subpath.substr(subpath.length - 5, 5);
if (metastr == ".meta") {
var jstr = fs.readFileSync(subpath, "utf-8");
var json = JSON.parse(jstr);
if (uuidUtils.isUuid(json["uuid"])) {
this.updateUuidMap(json);
if (json["subMetas"] && typeof json["subMetas"] == "object") {
for (var bb in json["subMetas"]) {
this.updateUuidMap(json["subMetas"][bb]);
}
}
}
}
}
}
},
updateUuidMap: function (json) {
if (uuidUtils.isUuid(json["uuid"]) && !uuidMap[json["uuid"]]) {
uuidMap[json["uuid"]] = {
uuid: uuidUtils.uuidv4(),
};
if (uuidUtils.isUuid(json["rawTextureUuid"])) {
uuidMap[json["rawTextureUuid"]] = {
uuid: uuidUtils.uuidv4(),
};
}
}
},
isReplaceFile: function (subpath) {
let conf = [".anim", ".prefab", ".fire", ".meta"];
for (let i = 0; i < conf.length; i++) {
let count = conf[i].length;
if (subpath.substr(subpath.length - count, count) == conf[i]) {
return true;
}
}
return false;
},
//递归目录找到所有需要替换uuid的文件
replaceDirUuid: function (dir) {
var stat = fs.statSync(dir);
if (!stat.isDirectory()) {
return;
}
var subpaths = fs.readdirSync(dir),
subpath;
for (var i = 0; i < subpaths.length; ++i) {
if (subpaths[i][0] === ".") {
continue;
}
subpath = path.join(dir, subpaths[i]);
stat = fs.statSync(subpath);
if (stat.isDirectory()) {
this.replaceDirUuid(subpath);
} else if (stat.isFile()) {
if (this.isReplaceFile(subpath)) {
var jstr = fs.readFileSync(subpath, "utf-8");
var json;
try {
json = JSON.parse(jstr);
} catch (error) {
console.log(subpath);
}
if (json) {
this.replaceFileUuid(json);
fs.writeFileSync(subpath, JSON.stringify(json, null, 2));
}
}
}
}
},
//递归json对象找到所有需要替换uuid
replaceFileUuid: function (json) {
if (json && typeof json == "object") {
if (json["uuid"] && uuidUtils.isUuid(json["uuid"])) {
json["uuid"] = uuidMap[json["uuid"]].uuid;
}
if (json["rawTextureUuid"] && uuidUtils.isUuid(json["rawTextureUuid"])) {
json["rawTextureUuid"] = uuidMap[json["rawTextureUuid"]].uuid;
}
if (json["textureUuid"] && uuidUtils.isUuid(json["textureUuid"])) {
json["textureUuid"] = uuidMap[json["textureUuid"]].uuid;
}
var uuidStr = json["__uuid__"];
if (uuidStr && uuidUtils.isUuid(uuidStr)) {
//资源
if (Reg_Uuid.test(uuidStr)) {
if (uuidMap[uuidStr]) {
json["__uuid__"] = uuidMap[uuidStr].uuid;
}
} else {
var uuidStr = uuidUtils.decompressUuid(uuidStr);
if (uuidMap[uuidStr]) {
json["__uuid__"] = UuidUtils.compressUuid(
uuidMap[uuidStr],
false
);
}
}
}
var typeStr = json["__type__"];
if (typeStr && uuidUtils.isUuid(typeStr)) {
//自定义脚本
if (Reg_Uuid.test(typeStr)) {
if (uuidMap[typeStr]) {
json["__type__"] = uuidMap[typeStr].uuid;
}
} else {
//cocos为了减少数据量,做了一次特殊的 base64 编码
var de__type__ = uuidUtils.decompressUuid(typeStr);
if (uuidMap[de__type__]) {
json["__type__"] = uuidUtils.compressUuid(
uuidMap[de__type__].uuid,
false
);
}
}
}
if (Object.prototype.toString.call(json) === "[object Array]") {
for (var prebidx = 0; prebidx < json.length; prebidx++) {
if (json[prebidx] && typeof json[prebidx] == "object") {
this.replaceFileUuid(json[prebidx]);
}
}
} else if (Object.prototype.toString.call(json) === "[object Object]") {
for (var prebidx in json) {
if (json[prebidx] && typeof json[prebidx] == "object") {
this.replaceFileUuid(json[prebidx]);
}
}
}
}
},
};
/**
* 2.0之后才有Editor.Utils.UuidUtils.compressUuid | decompressUuid的转换
* 这里主要处理base和uuid转换,其他由node-uuid库提供
*/
var Uuid = require("node-uuid");
var Base64KeyChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var AsciiTo64 = new Array(128);
for (var i = 0; i < 128; ++i) {
AsciiTo64[i] = 0;
}
for (i = 0; i < 64; ++i) {
AsciiTo64[Base64KeyChars.charCodeAt(i)] = i;
}
var Reg_Dash = /-/g;
var Reg_Uuid = /^[0-9a-fA-F-]{36}$/;
var Reg_NormalizedUuid = /^[0-9a-fA-F]{32}$/;
var Reg_CompressedUuid = /^[0-9a-zA-Z+/]{22,23}$/;
var UuidUtils = {
compressUuid: function (uuid, min) {
if (Reg_Uuid.test(uuid)) {
uuid = uuid.replace(Reg_Dash, "");
} else if (!Reg_NormalizedUuid.test(uuid)) {
return uuid;
}
var reserved = min === true ? 2 : 5;
return UuidUtils.compressHex(uuid, reserved);
},
compressHex: function (hexString, reservedHeadLength) {
var length = hexString.length;
var i;
if (typeof reservedHeadLength !== "undefined") {
i = reservedHeadLength;
} else {
i = length % 3;
}
var head = hexString.slice(0, i);
var base64Chars = [];
while (i < length) {
var hexVal1 = parseInt(hexString[i], 16);
var hexVal2 = parseInt(hexString[i + 1], 16);
var hexVal3 = parseInt(hexString[i + 2], 16);
base64Chars.push(Base64KeyChars[(hexVal1 << 2) | (hexVal2 >> 2)]);
base64Chars.push(Base64KeyChars[((hexVal2 & 3) << 4) | hexVal3]);
i += 3;
}
return head + base64Chars.join("");
},
decompressUuid: function (str) {
if (str.length === 23) {
// decode base64
var hexChars = [];
for (var i = 5; i < 23; i += 2) {
var lhs = AsciiTo64[str.charCodeAt(i)];
var rhs = AsciiTo64[str.charCodeAt(i + 1)];
hexChars.push((lhs >> 2).toString(16));
hexChars.push((((lhs & 3) << 2) | (rhs >> 4)).toString(16));
hexChars.push((rhs & 0xf).toString(16));
}
//
str = str.slice(0, 5) + hexChars.join("");
} else if (str.length === 22) {
// decode base64
var hexChars = [];
for (var i = 2; i < 22; i += 2) {
var lhs = AsciiTo64[str.charCodeAt(i)];
var rhs = AsciiTo64[str.charCodeAt(i + 1)];
hexChars.push((lhs >> 2).toString(16));
hexChars.push((((lhs & 3) << 2) | (rhs >> 4)).toString(16));
hexChars.push((rhs & 0xf).toString(16));
}
//
str = str.slice(0, 2) + hexChars.join("");
}
return [
str.slice(0, 8),
str.slice(8, 12),
str.slice(12, 16),
str.slice(16, 20),
str.slice(20),
].join("-");
},
isUuid: function (str) {
if (typeof str == "string") {
return (
Reg_CompressedUuid.test(str) ||
Reg_NormalizedUuid.test(str) ||
Reg_Uuid.test(str)
);
} else {
return false;
}
},
uuid: function () {
var uuid = Uuid.v4();
return UuidUtils.compressUuid(uuid, true);
},
uuidv4: function () {
var uuid = Uuid.v4();
return uuid;
},
};
module.exports = UuidUtils;
{ {
"title": "play", "title": "play",
"packageName": "org.cocos2d.demo", "packageName": "org.cocos2d.demo",
"startScene": "76bcad6c-e132-49f4-81c8-7590d4c053b8", "startScene": "0737ce42-24f0-45c6-8e1a-8bdab4f74ba3",
"excludeScenes": [], "excludeScenes": [],
"includeSDKBox": false, "includeSDKBox": false,
"orientation": { "orientation": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment