scene_ex.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. *场景逻辑扩展
  3. *删除选中的节点以及节点所绑定的脚本
  4. */
  5. 'use strict';
  6. var path = require('path');
  7. var fs = require('fs');
  8. module.exports = {
  9. /************* 事件 *************/
  10. messages:
  11. {
  12. 'getWidgetBindEvents':(event,args,parent)=>
  13. {
  14. let node = args.uuid && parent.findNode(args.uuid);
  15. if (!node) {
  16. event.reply(null);
  17. return
  18. }
  19. let list = [];
  20. node.getComponents(cc.Component).forEach((_comp)=>{
  21. if(_comp && _comp.clickEvents && _comp.clickEvents.length)
  22. {
  23. for(let myeee of _comp.clickEvents)
  24. {
  25. if(!myeee || !myeee.target) continue;
  26. let buttonTargetNode = myeee.target;
  27. let comps = buttonTargetNode.getComponents(cc.Component);
  28. if(comps && comps.length)
  29. {
  30. for(let comp of comps)
  31. {
  32. if(comp.__scriptUuid && comp.__classname__ && (comp.__classname__ === myeee._componentName || comp.__classname__ === myeee.component))
  33. {
  34. if(comp.__classname__.indexOf(".") == -1){
  35. list.push({
  36. name : comp.__classname__,
  37. scriptUuid :comp.__scriptUuid,
  38. funcName : myeee.handler,
  39. })
  40. };
  41. }
  42. }
  43. }
  44. }
  45. }
  46. });
  47. event.reply(null,list);
  48. },
  49. }
  50. };