need to compress uuid when build project in non-debug mode (#4449)

refine
This commit is contained in:
Santy-Wang
2019-05-20 09:12:06 +08:00
committed by Weiliang Wang
parent 60df1a6da9
commit 7cf389748a
4 changed files with 32 additions and 9 deletions
+10 -3
View File
@@ -202,17 +202,24 @@ export class TextureCube extends TextureBase {
this.mipmaps = [];
}
public _serialize () {
public _serialize (exporting?: any) {
return {
base: super._serialize(),
mipmaps: this._mipmaps.map((mipmap) => {return {
mipmaps: this._mipmaps.map((mipmap) => exporting ? {
front: Editor.Utils.UuidUtils.compressUuid(mipmap.front._uuid, true),
back: Editor.Utils.UuidUtils.compressUuid(mipmap.back._uuid, true),
left: Editor.Utils.UuidUtils.compressUuid(mipmap.left._uuid, true),
right: Editor.Utils.UuidUtils.compressUuid(mipmap.right._uuid, true),
top: Editor.Utils.UuidUtils.compressUuid(mipmap.top._uuid, true),
bottom: Editor.Utils.UuidUtils.compressUuid(mipmap.bottom._uuid, true),
} : {
front: mipmap.front._uuid,
back: mipmap.back._uuid,
left: mipmap.left._uuid,
right: mipmap.right._uuid,
top: mipmap.top._uuid,
bottom: mipmap.bottom._uuid,
}; }),
}),
};
}
+11 -3
View File
@@ -99,12 +99,20 @@ export class SpriteAtlas extends Asset {
return frames;
}
public _serialize () {
public _serialize (exporting?: any) {
const frames: string[] = [];
for (const key of Object.keys(this.spriteFrames)) {
const spriteFrame = this.spriteFrames[key];
const id = spriteFrame ? spriteFrame._uuid : '';
const name = id.split('@')[1];
let id = spriteFrame ? spriteFrame._uuid : '';
const strs = id.split('@');
const uuid = strs[0];
const name = strs[1];
if (id && exporting) {
id = Editor.Utils.UuidUtils.compressUuid(uuid, true);
if (name) {
id = id + `@${name}`;
}
}
frames.push(name);
frames.push(id);
}
+6 -1
View File
@@ -199,7 +199,12 @@ export class Texture2D extends TextureBase {
public _serialize (exporting?: any): any {
return {
base: super._serialize(exporting),
mipmaps: this._mipmaps.map((mipmap) => mipmap._uuid),
mipmaps: this._mipmaps.map((mipmap) => {
if (exporting) {
return Editor.Utils.UuidUtils.compressUuid(mipmap._uuid, true);
}
return mipmap._uuid;
}),
};
}
+5 -2
View File
@@ -34,7 +34,10 @@ const Indices = UuidTemplate.map((x, i) => x === '-' ? NaN : i).filter(isFinite)
// fcmR3XADNLgJ1ByKhqcC5Z -> fc991dd7-0033-4b80-9d41-c8a86a702e59
export default function decodeUuid (base64) {
if (base64.length !== 22) {
const strs = base64.split('@');
const name = strs[1];
const uuid = strs[0];
if (uuid.length !== 22) {
return base64;
}
UuidTemplate[0] = base64[0];
@@ -46,7 +49,7 @@ export default function decodeUuid (base64) {
UuidTemplate[Indices[j++]] = HexChars[((lhs & 3) << 2) | rhs >> 4];
UuidTemplate[Indices[j++]] = HexChars[rhs & 0xF];
}
return UuidTemplate.join('');
return name ? UuidTemplate.join('') + `@${name}` : UuidTemplate.join('');
}
if (CC_TEST) {