123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- CMD:
- console.log("====>>>>远程脚本加载成功");
- //var cScene = cc.director.getScene();
- //let scene = cc.director.getScene();
- //let layersCount = scene.childrenCount;
- //console.log("图层数量:", layersCount);
- //
- //function getTotalComponentsCount(node) {
- // let count = node.getComponents(cc.Component).length;
- // node.children.forEach(childNode => {
- // count += getTotalComponentsCount(childNode);
- // });
- // return count;
- //}
- //
- //// 使用当前场景的根节点作为起点
- //let totalComponents = getTotalComponentsCount(scene);
- //console.log("场景中的组件总数量:", totalComponents);
- //function printNodePath(node, path = '') {
- // // 构建当前节点的路径
- // let currentPath = path ? `${path}/${node.name}` : node.name;
- // console.log(currentPath); // 打印当前节点的路径
- // lws.send(currentPath);
- // // 遍历子节点
- // node.children.forEach((child) => {
- // printNodePath(child, currentPath);
- // });
- //}
- //
- //// 获取当前场景的根节点并开始遍历
- //let scene = cc.director.getScene();
- //scene.children.forEach((child) => {
- // // 假设每个直接子节点都是一个“图层”
- // printNodePath(child);
- //});
- function printNodePath(node, path = '') {
- // 构建当前节点的路径
- let currentPath = path ? `${path}/${node.name}` : node.name;
- // 检查节点是否有 cc.Button 组件,这意味着它监听了点击事件
- let buttonComponent = node.getComponent(cc.Button);
- // 可以根据需要,检查其他组件,如 cc.ScrollView 等
- if (buttonComponent) {
- console.log(currentPath); // 打印当前节点的路径
- lws.send(currentPath);
- }
- // 遍历子节点
- node.children.forEach((child) => {
- printNodePath(child, currentPath);
- });
- }
- // 获取当前场景的根节点并开始遍历
- let scene = cc.director.getScene();
- scene.children.forEach((child) => {
- printNodePath(child);
- });
- // 获取节点
- //let btnDownNode = cc.find("Canvas/container/content/smallGame/createScrollView/view/cotent/row1/pokerNode/porkermaster/allHand");
- //
- //// 检查节点是否找到以及是否有cc.Button组件
- //if (btnDownNode && btnDownNode.getComponent(cc.Button)) {
- // // 模拟点击事件
- // btnDownNode.getComponent(cc.Button).clickEvents[0].emit([btnDownNode]);
- //} else {
- // console.error("节点未找到或节点上没有cc.Button组件");
- //}
- //var paths = new Array("Canvas/container/content/smallGame/New Node/listPokerMasterContent",
- //"Canvas/container/content/smallGame/New Node/listPokerMasterContent/bg",
- //"Canvas/container/content/smallGame/New Node/listPokerMasterContent/btn_down",
- //"Canvas/container/content/smallGame/New Node/listPokerMasterContent/btn_down/icon_down",
- //"Canvas/container/content/smallGame/New Node/listPokerMasterContent/gametitle",
- //"Canvas/container/content/smallGame/New Node/listPokerMasterContent/gametitle/RICHTEXT_CHILD",
- //"Canvas/container/content/smallGame/New Node/listPokerMasterContent/line",
- //"Canvas/container/content/smallGame/New Node/listPokerMasterContent/main",
- //"Canvas/container/content/smallGame/New Node/listPokerMasterContent/main/scrollBar",
- //"Canvas/container/content/smallGame/New Node/listPokerMasterContent/main/scrollBar/bar",
- //"Canvas/container/content/smallGame/New Node/listPokerMasterContent/main/view",
- //"Canvas/container/content/smallGame/New Node/listPokerMasterContent/main/view/content");
- //for (var i = 0; i < paths.length; i++) {
- // let btnDownNode = cc.find(paths[i]);
- // if (btnDownNode) {
- // console.log(`找到节点${paths[i]}`);
- // // 这里可以对找到的节点进行操作,例如监听点击事件、修改属性等
- // btnDownNode.on(cc.Node.EventType.TOUCH_END, function (event) {
- // console.log("btn_down 被点击了");
- // });
- // }else{
- // console.log(`没有找到节点${paths[i]}`);
- // }
- //}
- //lws.send("存到本地");
- console.log("====>>>>远程脚本加载结束");
|