12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- 'use strict';
- let eventFuncs =
- {
- 'set-active'(event){
- let nodes = Editor.Selection.curSelection('node');
- if (nodes && nodes.length != 0)
- {
- let active = cc.engine.getInstanceById(nodes[0]).active;
- for (let i = 0; i < nodes.length; i++)
- {
- const id = nodes[i];
- let node = cc.engine.getInstanceById(id)
- if(node){
- // node.active = active;
- this.setNodeActive(node.uuid,!active)
- }
- }
- Editor.Ipc.sendToAll('scene:undo-commit');
- }
- },
- // 显示选择node同时隐藏同层node
- 'set-active-radio'(event){
- let nodes = Editor.Selection.curSelection('node');
- if (nodes && nodes.length != 0)
- {
- let node = cc.engine.getInstanceById(nodes[0]);
- let active = node.active;
- if(node.parent){
- for (let i = 0; i < node.parent.children.length; i++)
- {
- const childrenNode = node.parent.children[i];
- // childrenNode.active = childrenNode != node ? !active : active;
- const isSelectUuid = nodes.includes(childrenNode.uuid)
- this.setNodeActive(childrenNode.uuid,isSelectUuid ? !active : active)
- }
- Editor.Ipc.sendToAll('scene:undo-commit');
- }
- }
- },
-
- setNodeActive(uuid,active){
- Editor.Ipc.sendToPanel("scene", "scene:set-property",{
- id: uuid,
- path: 'active',//要修改的属性
- type: 'Boolean',
- value: active,
- isSubProp: false,
- });
- },
- };
- module.exports = eventFuncs;
|