震惊!2D碰撞竟然可以******

碰撞区域选中节点 就会显示 画出来的区域,现在 我需要 这个需要 一直显示要怎么搞?

需求:碰撞区域要在 编辑器中一直显示

使用 cc.game.once(cc.Game.EVENT_ENGINE_INITED, function () + cc.js.mixin 可以 实现吗?

又或者 说 需要写个扩展插件??

上镇楼图

image

2赞

自己画出来就可以了呗 :face_with_monocle: :face_with_monocle:

社死钓鱼吗,我在单位打开。。。

使用executeInEditMode装饰器
@executeInEditMode(true)
这样组件就可以在编辑器中运行了

又或者 使用 Editor.Scene.callSceneScript

楼上的那个,脚本可以在编辑器使用了,具体怎么去搞 还在研究中

自己使用 划线 api 又 画了一遍 就显示 出来的

private drawCollider() {
this.graphics.clear();
this.graphics.lineWidth = 20;
const points = this.collider.points;
if (points.length > 0) {
this.graphics.moveTo(points[0].x, points[0].y);

        for (let i = 1; i < points.length; i++) {
            this.graphics.lineTo(points[i].x, points[i].y);
        }
        this.graphics.lineTo(points[0].x, points[0].y); // 闭合路径
        this.graphics.stroke();
    }
}
1赞