local Editor = class("Editor") function Editor:activate() end function Editor:unactivate() end function Editor:play() end function Editor:stop() end function Editor:save(filename) end function Editor:relayoutAll() end -- 自动命名成不重名 function Editor:autoSetNodeName(node) if not self.node then return; end local names = {}; self.node:visitNode(function(child) if child ~= node then names[child:getName()] = child; end return true; end); while(names[node:getName()]) do local name = node:getName(); local ret , matchNum = string.gsub(name , "(.*_)([0-9]+)$" , function(...) local args = {...} return args[1] .. tostring(tonumber(args[2]) + 1); end); if matchNum == 0 then node:setName(ret .. "_1"); else node:setName(ret); end end -- 所有子节点也要做这个处理 for i , child in pairs(node:getChildren()) do self:autoSetNodeName(child); end end return Editor;