需求:将指定预制体下的有规则的节点(比如有,Find脚本),通过编辑器的方式,一键生成到Find的properties属性,
这样的方式代替手动一个一个拖拽
进度:目前我自己通过文档的方式做到了能够通过编辑器查找节点,并获得相应规则的节点,但是怎么去保存节点对象,这个问题把我难到了~,有大神指点下么?
module.exports = {
‘get-canvas-children’: function (event) {
var uids = Editor.Selection.curSelection(‘node’)
uids.forEach(function (uid) {
var that = this
Editor.Ipc.sendToPanel(‘scene’, ‘scene:query-node-info’, uid, ‘cc.Node’, (error, info) => {
if (error)
return Editor.error(error);
var _ui = cc.find(info.name);
//TODO: ui下的指定节点保存起来
});
}.bind(this));
},
// 前缀@或者带有FindFlag的脚本 || 前缀#表示忽略查找他的子节点
findFlagNode: function (obj, _root) {
if (this.isHaveFlag(_root)) {
obj[_root.name] = _root
}
if (_root.children.length > 0) {
for (var i = 0, len = _root.children.length; i < len; i++) {
let _subNode = _root.children[i]
this.findFlagNode(obj, _subNode)
}
}
},
isHaveFlag(node) {
return node.getComponent("FindF") != undefined
},
};