scene-info.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. 'use strict';
  2. let eventFuncs =
  3. {
  4. 'set-active'(event){
  5. let nodes = Editor.Selection.curSelection('node');
  6. if (nodes && nodes.length != 0)
  7. {
  8. let active = cc.engine.getInstanceById(nodes[0]).active;
  9. for (let i = 0; i < nodes.length; i++)
  10. {
  11. const id = nodes[i];
  12. let node = cc.engine.getInstanceById(id)
  13. if(node){
  14. // node.active = active;
  15. this.setNodeActive(node.uuid,!active)
  16. }
  17. }
  18. Editor.Ipc.sendToAll('scene:undo-commit');
  19. }
  20. },
  21. // 显示选择node同时隐藏同层node
  22. 'set-active-radio'(event){
  23. let nodes = Editor.Selection.curSelection('node');
  24. if (nodes && nodes.length != 0)
  25. {
  26. let node = cc.engine.getInstanceById(nodes[0]);
  27. let active = node.active;
  28. if(node.parent){
  29. for (let i = 0; i < node.parent.children.length; i++)
  30. {
  31. const childrenNode = node.parent.children[i];
  32. // childrenNode.active = childrenNode != node ? !active : active;
  33. const isSelectUuid = nodes.includes(childrenNode.uuid)
  34. this.setNodeActive(childrenNode.uuid,isSelectUuid ? !active : active)
  35. }
  36. Editor.Ipc.sendToAll('scene:undo-commit');
  37. }
  38. }
  39. },
  40. setNodeActive(uuid,active){
  41. Editor.Ipc.sendToPanel("scene", "scene:set-property",{
  42. id: uuid,
  43. path: 'active',//要修改的属性
  44. type: 'Boolean',
  45. value: active,
  46. isSubProp: false,
  47. });
  48. },
  49. };
  50. module.exports = eventFuncs;