Commit bd21a152 authored by 李维's avatar 李维

测试

parent 993c1ef1
{
"ver": "1.1.2",
"uuid": "06b000db-989f-4c27-936d-b16fbb538f9e",
"uuid": "6927db8f-12a4-4b92-b80d-81b6c0739893",
"isBundle": false,
"bundleName": "",
"priority": 1,
......
{
"ver": "2.0.1",
"uuid": "4b1da1d2-508b-4a44-a4f7-646a584bcd09",
"uuid": "c8749a73-870c-4d16-822b-b239a8df01d9",
"downloadMode": 0,
"duration": 0.130612,
"subMetas": {}
......
{
"ver": "1.1.2",
"uuid": "c1e03ef0-75d0-4b0f-8c4a-3b0c4c3c0eb8",
"uuid": "dcb19a12-3740-4da4-bb1e-031290059858",
"isBundle": false,
"bundleName": "",
"priority": 1,
......
{
"ver": "1.1.2",
"uuid": "5c5ec4e7-b4be-40e5-b46d-a594531f1926",
"uuid": "46c7a43b-b19d-4d4c-992b-0f3c0b39bd0e",
"isBundle": false,
"bundleName": "",
"priority": 1,
......
{
"ver": "1.1.0",
"uuid": "f8eba8ce-91d8-407b-8b9a-6a13e75705de",
"uuid": "d129bde1-7a86-4690-8685-790edcd78e56",
"subMetas": {}
}
\ No newline at end of file
{
"ver": "1.1.2",
"uuid": "e91cb0a0-d89f-4e36-a2de-55bb855e3486",
"uuid": "22d21a96-1507-41bb-a42d-6e8f9c77567e",
"isBundle": false,
"bundleName": "",
"priority": 1,
......
{
"ver": "1.0.8",
"uuid": "3e9b256d-8357-4801-a550-29577eeb7283",
"uuid": "1cc98882-6ac2-45bc-97ec-38ceeac9d774",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
......
......@@ -320,7 +320,7 @@
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "24312cef-5065-469d-8aa8-6a96308ce6c7"
"__uuid__": "09c66b1f-c4ed-47e4-8724-086f3abf2ce9"
},
"_type": 0,
"_sizeMode": 1,
......@@ -482,7 +482,7 @@
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "857aaac5-5f4b-475e-ba66-849b2ea762a1"
"__uuid__": "59b81c11-a9f3-4b40-b00a-372e8bcf8053"
},
"_type": 0,
"_sizeMode": 1,
......@@ -647,7 +647,7 @@
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "99be3acb-feed-4630-90ed-874b4b37fdb7"
"__uuid__": "05ec9c3c-62ba-40c1-a62f-62fb4a7bdc90"
},
"_type": 0,
"_sizeMode": 1,
......@@ -940,7 +940,7 @@
"_lineHeight": 40,
"_enableWrapText": true,
"_N$file": {
"__uuid__": "f8eba8ce-91d8-407b-8b9a-6a13e75705de"
"__uuid__": "d129bde1-7a86-4690-8685-790edcd78e56"
},
"_isSystemFontUsed": false,
"_spacingX": 0,
......@@ -1090,7 +1090,7 @@
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "92c0962c-a7ba-4ece-9198-38409ec56c0d"
"__uuid__": "3a8ab6be-307e-441c-a6c9-94daea1a62ba"
},
"_type": 0,
"_sizeMode": 1,
......@@ -1239,7 +1239,7 @@
},
"_enabled": true,
"_clip": {
"__uuid__": "4b1da1d2-508b-4a44-a4f7-646a584bcd09"
"__uuid__": "c8749a73-870c-4d16-822b-b239a8df01d9"
},
"_volume": 1,
"_mute": false,
......@@ -1294,7 +1294,7 @@
"_id": "29zXboiXFBKoIV4PQ2liTe"
},
{
"__type__": "932781+VoNLW4PlVe5IkvZu",
"__type__": "858c95E7DxIQ7GL8/wXm5YL",
"_name": "",
"_objFlags": 0,
"node": {
......@@ -1304,7 +1304,7 @@
"_id": "eaTVUpqahPfZeO9+sUI7RP"
},
{
"__type__": "3e9b2Vtg1dIAaVQKVd+63KD",
"__type__": "1cc98iCasJFvJfsOM7qydd0",
"_name": "",
"_objFlags": 0,
"node": {
......
{
"ver": "1.2.9",
"uuid": "76bcad6c-e132-49f4-81c8-7590d4c053b8",
"uuid": "bde7b96c-d33d-429d-8c6b-ae0af1a8d62b",
"asyncLoadAssets": false,
"autoReleaseAssets": true,
"subMetas": {}
......
{
"ver": "1.0.8",
"uuid": "93278d7e-5683-4b5b-83e5-55ee4892f66e",
"uuid": "858c9e44-ec3c-4843-b18b-f3fc179b960b",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
......
{
"ver": "1.1.2",
"uuid": "fc90545a-71a6-464b-8fb6-8543ad174c3b",
"uuid": "7fc99075-3b3b-4204-bdac-6837b65b349d",
"isBundle": false,
"bundleName": "",
"priority": 1,
......
{
"ver": "1.0.8",
"uuid": "8ab8d2f2-7a80-46c0-8fe8-3168666b73c0",
"uuid": "090f53c7-81c5-42fc-9bee-343164b8f6b1",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
......
{
"ver": "1.0.8",
"uuid": "2b196038-fa59-44ea-b78e-867d01f5ffb1",
"uuid": "1f8206fb-3413-4817-be4d-9adb7d4e0ee8",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
......
{
"ver": "1.0.8",
"uuid": "0a4202f3-2347-46fb-bc56-570881f466cc",
"uuid": "314d036c-b824-4b4f-b0cb-83a39510db2e",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
......
{
"ver": "1.0.8",
"uuid": "45c50178-f68a-47fc-b45f-18e1ffa1a378",
"uuid": "58d81fe3-4f52-4213-8872-834f4d22458b",
"isPlugin": true,
"loadPluginInWeb": true,
"loadPluginInNative": true,
......
{
"ver": "1.0.8",
"uuid": "448fbc4d-68a4-496a-8470-afbdc186fcdc",
"uuid": "a81b1f6f-85b4-4c1c-83ea-74ba1fd6e17a",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
......
{
"ver": "1.1.2",
"uuid": "cf8a2c4b-324d-423f-bdc8-4c4ea37cb883",
"uuid": "03f94607-cd21-464c-973e-1c509d0c35f8",
"isBundle": false,
"bundleName": "",
"priority": 1,
......
{
"ver": "2.3.5",
"uuid": "cbc8d01b-d508-43bf-99ee-0b8d51ae2cf6",
"uuid": "2fb8cf44-efcd-46c7-90fd-3f23a7a742c2",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
......@@ -13,8 +13,8 @@
"subMetas": {
"1orange": {
"ver": "1.0.4",
"uuid": "f88adbc6-4f0b-48ea-a67d-108e3710bcf5",
"rawTextureUuid": "cbc8d01b-d508-43bf-99ee-0b8d51ae2cf6",
"uuid": "f296f100-5645-414b-8490-ba63d732d600",
"rawTextureUuid": "2fb8cf44-efcd-46c7-90fd-3f23a7a742c2",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
......
{
"ver": "2.3.5",
"uuid": "6f264096-521f-4028-ba62-ee4d026c7db0",
"uuid": "82ad5851-aa98-4511-8094-ea297eabb201",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
......@@ -13,8 +13,8 @@
"subMetas": {
"bg": {
"ver": "1.0.4",
"uuid": "24312cef-5065-469d-8aa8-6a96308ce6c7",
"rawTextureUuid": "6f264096-521f-4028-ba62-ee4d026c7db0",
"uuid": "09c66b1f-c4ed-47e4-8724-086f3abf2ce9",
"rawTextureUuid": "82ad5851-aa98-4511-8094-ea297eabb201",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
......
{
"ver": "2.3.5",
"uuid": "3272a92c-a6dc-4242-a5df-10d45b6faf8c",
"uuid": "e7b4cd35-d6ba-4962-b09a-9c4a56b64472",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
......@@ -13,8 +13,8 @@
"subMetas": {
"btn_left": {
"ver": "1.0.4",
"uuid": "857aaac5-5f4b-475e-ba66-849b2ea762a1",
"rawTextureUuid": "3272a92c-a6dc-4242-a5df-10d45b6faf8c",
"uuid": "59b81c11-a9f3-4b40-b00a-372e8bcf8053",
"rawTextureUuid": "e7b4cd35-d6ba-4962-b09a-9c4a56b64472",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
......
{
"ver": "2.3.5",
"uuid": "7d25208c-d59f-4011-ae49-46eb95b5828f",
"uuid": "8cf9c5c5-8104-4dca-a73b-db2f608a3c77",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
......@@ -13,8 +13,8 @@
"subMetas": {
"btn_right": {
"ver": "1.0.4",
"uuid": "99be3acb-feed-4630-90ed-874b4b37fdb7",
"rawTextureUuid": "7d25208c-d59f-4011-ae49-46eb95b5828f",
"uuid": "05ec9c3c-62ba-40c1-a62f-62fb4a7bdc90",
"rawTextureUuid": "8cf9c5c5-8104-4dca-a73b-db2f608a3c77",
"trimType": "auto",
"trimThreshold": 1,
"rotated": false,
......
{
"ver": "2.3.5",
"uuid": "bd9afd8c-b5ec-4f8f-8d38-396ca84a4358",
"uuid": "542dfdf1-97af-4a73-914e-e314495084ec",
"type": "sprite",
"wrapMode": "clamp",
"filterMode": "bilinear",
......@@ -13,8 +13,8 @@
"subMetas": {
"icon": {
"ver": "1.0.4",
"uuid": "92c0962c-a7ba-4ece-9198-38409ec56c0d",
"rawTextureUuid": "bd9afd8c-b5ec-4f8f-8d38-396ca84a4358",
"uuid": "3a8ab6be-307e-441c-a6c9-94daea1a62ba",
"rawTextureUuid": "542dfdf1-97af-4a73-914e-e314495084ec",
"trimType": "auto",
"trimThreshold": 1,
"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;
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