fix:界面拉伸适配. add:支持cocos animation,spine,dragonbones等文件导入.

This commit is contained in:
YipLee
2021-01-22 00:02:49 +08:00
parent c4f716c8e9
commit c232a91a41
23 changed files with 2590 additions and 2028 deletions

View File

@@ -1,4 +1,6 @@
import Setting from "../../editor/Setting";
import Events, { EventName } from "../util/Events";
import Tool from "../util/Tool";
const { ccclass, property } = cc._decorator;
@@ -36,7 +38,7 @@ export default class ResizeArea extends cc.Component {
this.Target.updateAlignment();
Events.emit(EventName.RESIZE, this.Target.node);
this.updateWidget(this.Target.node);
Setting.save();
}
private onTouchStart(event: cc.Event.EventTouch) {
@@ -61,12 +63,4 @@ export default class ResizeArea extends cc.Component {
private onMouseLeave(event: cc.Event.EventMouse) {
this._canvas.style.cursor = 'default ';
}
private updateWidget(node: cc.Node) {
node.children.forEach((c) => {
let widget = c.getComponent(cc.Widget);
widget && widget.updateAlignment();
this.updateWidget(c);
});
}
}

View File

@@ -105,4 +105,20 @@ export default class Tool {
arr.splice(idx, 1);
return true
}
/**
* 递归遍历所有子节点并更新widget组件
* @param node 目标节点,需遍历其子节点
* @param ignoreList 忽略节点,这些节点的子节点跳过遍历
*/
public static updateWidget(node: cc.Node, ...ignoreList: cc.Node[]) {
node.children.forEach((c) => {
let widget = c.getComponent(cc.Widget);
widget && widget.updateAlignment();
if (this.arrayHas(ignoreList, c)) {
return;
}
this.updateWidget(c, ...ignoreList);
});
}
}