mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-02 08:42:43 +08:00
need to compress uuid when build project in non-debug mode (#4449)
refine
This commit is contained in:
committed by
Weiliang Wang
parent
60df1a6da9
commit
7cf389748a
@@ -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,
|
||||
}; }),
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user