Cocos Creator 中根据uuid快速定位资源
Posted roger-jc
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Cocos Creator 中根据uuid快速定位资源相关的知识,希望对你有一定的参考价值。
var BASE64_KEYS = ‘ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=‘; var BASE64_VALUES = new Array(123); // max char code in base64Keys for (let i = 0; i < 123; ++i) BASE64_VALUES[i] = 64; // fill with placeholder(‘=‘) index for (let i = 0; i < 64; ++i) BASE64_VALUES[BASE64_KEYS.charCodeAt(i)] = i; // decoded value indexed by base64 char code Base64Values = BASE64_VALUES; var HexChars = ‘0123456789abcdef‘.split(‘‘); var _t = [‘‘, ‘‘, ‘‘, ‘‘]; var UuidTemplate = _t.concat(_t, ‘-‘, _t, ‘-‘, _t, ‘-‘, _t, ‘-‘, _t, _t, _t); var Indices = UuidTemplate.map(function (x, i) { return x === ‘-‘ ? NaN : i; }).filter(isFinite); // fcmR3XADNLgJ1ByKhqcC5Z -> fc991dd7-0033-4b80-9d41-c8a86a702e59 module.exports = function (base64) { if (base64.length !== 22) { return base64; } UuidTemplate[0] = base64[0]; UuidTemplate[1] = base64[1]; for (var i = 2, j = 2; i < 22; i += 2) { var lhs = Base64Values[base64.charCodeAt(i)]; var rhs = Base64Values[base64.charCodeAt(i + 1)]; UuidTemplate[Indices[j++]] = HexChars[lhs >> 2]; UuidTemplate[Indices[j++]] = HexChars[((lhs & 3) << 2) | rhs >> 4]; UuidTemplate[Indices[j++]] = HexChars[rhs & 0xF]; } return UuidTemplate.join(‘‘); }; // if (CC_TEST) { // cc._Test.decodeUuid = module.exports; // } var uuid = module.exports("d3u9uUb6lEnqDsTfYrxOdp") console.log(uuid)
以上是关于Cocos Creator 中根据uuid快速定位资源的主要内容,如果未能解决你的问题,请参考以下文章
进击3D游戏界!Cocos Creator快速实现骨骼动画交互!
进击3D游戏界!Cocos Creator快速实现骨骼动画交互!
Cocos Creator插件——Many Widgets助你快速开发
Cocos Creator插件——Many Widgets助你快速开发