CustomParse.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.CustomParse = void 0;
  4. const BaseComParse_1 = require("./BaseComParse");
  5. class CustomParse extends BaseComParse_1.BaseComParse {
  6. async parse(json, uuidSeekedMap, fatherJson) {
  7. let walkedMap = new Map();
  8. let ret = [];
  9. if (Editor.Utils.UUID.isUUID(json.__type__)) {
  10. let uuid = Editor.Utils.UUID.decompressUUID(json.__type__);
  11. let assetInfo = await Editor.Message.request('asset-db', 'query-asset-info', uuid);
  12. this.comName = (assetInfo === null || assetInfo === void 0 ? void 0 : assetInfo.name) || json.__type__;
  13. if (!assetInfo) {
  14. ret.push(json.__type__);
  15. }
  16. }
  17. else {
  18. this.comName = json.__type__;
  19. }
  20. await this.walk(json, ret, '', uuidSeekedMap, fatherJson, walkedMap);
  21. return ret;
  22. }
  23. async walk(json, ret, propPath, uuidSeekedMap, fatherJson, walkedMap) {
  24. if (json instanceof Array) {
  25. for (let i = 0; i < json.length; i++) {
  26. let ele = json[i];
  27. if (ele)
  28. await this.walk(ele, ret, propPath + '[' + i + ']', uuidSeekedMap, fatherJson, walkedMap);
  29. }
  30. }
  31. else if (json instanceof Object) {
  32. if (json.__uuid__) {
  33. let uuid = json.__uuid__;
  34. if (!uuidSeekedMap.has(uuid)) {
  35. let url = await Editor.Message.request('asset-db', 'query-url', uuid);
  36. if (url) {
  37. uuidSeekedMap.set(uuid, true);
  38. }
  39. else {
  40. ret.push(propPath);
  41. }
  42. }
  43. }
  44. else if (json.__id__) {
  45. //引用了其他的json元素
  46. let otherJson = fatherJson[json.__id__];
  47. if (otherJson && !walkedMap.has(json.__id__) && otherJson.__type__ != 'cc.Node') {
  48. walkedMap.set(json.__id__, true);
  49. await this.walk(otherJson, ret, propPath, uuidSeekedMap, fatherJson, walkedMap);
  50. }
  51. }
  52. else {
  53. //迭代
  54. for (let k in json) {
  55. if (json[k]) {
  56. await this.walk(json[k], ret, propPath + '.' + k, uuidSeekedMap, fatherJson, walkedMap);
  57. }
  58. }
  59. }
  60. }
  61. }
  62. }
  63. exports.CustomParse = CustomParse;