script.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. CMD:
  2. console.log("====>>>>远程脚本加载成功");
  3. //var cScene = cc.director.getScene();
  4. //let scene = cc.director.getScene();
  5. //let layersCount = scene.childrenCount;
  6. //console.log("图层数量:", layersCount);
  7. //
  8. //function getTotalComponentsCount(node) {
  9. // let count = node.getComponents(cc.Component).length;
  10. // node.children.forEach(childNode => {
  11. // count += getTotalComponentsCount(childNode);
  12. // });
  13. // return count;
  14. //}
  15. //
  16. //// 使用当前场景的根节点作为起点
  17. //let totalComponents = getTotalComponentsCount(scene);
  18. //console.log("场景中的组件总数量:", totalComponents);
  19. //function printNodePath(node, path = '') {
  20. // // 构建当前节点的路径
  21. // let currentPath = path ? `${path}/${node.name}` : node.name;
  22. // console.log(currentPath); // 打印当前节点的路径
  23. // lws.send(currentPath);
  24. // // 遍历子节点
  25. // node.children.forEach((child) => {
  26. // printNodePath(child, currentPath);
  27. // });
  28. //}
  29. //
  30. //// 获取当前场景的根节点并开始遍历
  31. //let scene = cc.director.getScene();
  32. //scene.children.forEach((child) => {
  33. // // 假设每个直接子节点都是一个“图层”
  34. // printNodePath(child);
  35. //});
  36. function printNodePath(node, path = '') {
  37. // 构建当前节点的路径
  38. let currentPath = path ? `${path}/${node.name}` : node.name;
  39. // 检查节点是否有 cc.Button 组件,这意味着它监听了点击事件
  40. let buttonComponent = node.getComponent(cc.Button);
  41. // 可以根据需要,检查其他组件,如 cc.ScrollView 等
  42. if (buttonComponent) {
  43. console.log(currentPath); // 打印当前节点的路径
  44. lws.send(currentPath);
  45. }
  46. // 遍历子节点
  47. node.children.forEach((child) => {
  48. printNodePath(child, currentPath);
  49. });
  50. }
  51. // 获取当前场景的根节点并开始遍历
  52. let scene = cc.director.getScene();
  53. scene.children.forEach((child) => {
  54. printNodePath(child);
  55. });
  56. // 获取节点
  57. //let btnDownNode = cc.find("Canvas/container/content/smallGame/createScrollView/view/cotent/row1/pokerNode/porkermaster/allHand");
  58. //
  59. //// 检查节点是否找到以及是否有cc.Button组件
  60. //if (btnDownNode && btnDownNode.getComponent(cc.Button)) {
  61. // // 模拟点击事件
  62. // btnDownNode.getComponent(cc.Button).clickEvents[0].emit([btnDownNode]);
  63. //} else {
  64. // console.error("节点未找到或节点上没有cc.Button组件");
  65. //}
  66. //var paths = new Array("Canvas/container/content/smallGame/New Node/listPokerMasterContent",
  67. //"Canvas/container/content/smallGame/New Node/listPokerMasterContent/bg",
  68. //"Canvas/container/content/smallGame/New Node/listPokerMasterContent/btn_down",
  69. //"Canvas/container/content/smallGame/New Node/listPokerMasterContent/btn_down/icon_down",
  70. //"Canvas/container/content/smallGame/New Node/listPokerMasterContent/gametitle",
  71. //"Canvas/container/content/smallGame/New Node/listPokerMasterContent/gametitle/RICHTEXT_CHILD",
  72. //"Canvas/container/content/smallGame/New Node/listPokerMasterContent/line",
  73. //"Canvas/container/content/smallGame/New Node/listPokerMasterContent/main",
  74. //"Canvas/container/content/smallGame/New Node/listPokerMasterContent/main/scrollBar",
  75. //"Canvas/container/content/smallGame/New Node/listPokerMasterContent/main/scrollBar/bar",
  76. //"Canvas/container/content/smallGame/New Node/listPokerMasterContent/main/view",
  77. //"Canvas/container/content/smallGame/New Node/listPokerMasterContent/main/view/content");
  78. //for (var i = 0; i < paths.length; i++) {
  79. // let btnDownNode = cc.find(paths[i]);
  80. // if (btnDownNode) {
  81. // console.log(`找到节点${paths[i]}`);
  82. // // 这里可以对找到的节点进行操作,例如监听点击事件、修改属性等
  83. // btnDownNode.on(cc.Node.EventType.TOUCH_END, function (event) {
  84. // console.log("btn_down 被点击了");
  85. // });
  86. // }else{
  87. // console.log(`没有找到节点${paths[i]}`);
  88. // }
  89. //}
  90. //lws.send("存到本地");
  91. console.log("====>>>>远程脚本加载结束");