【BUG反馈】2.46,property 做 get set 的问题,属性在编辑器中无法创建

创建一个coord 属性的get set。

这样写是没问题的:

const { ccclass, property } = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {
    _coord: cc.Vec2 = null;
    @property(cc.Vec2)
    get coord(): cc.Vec2 {
        return this._coord;
    }
    set coord(cr: cc.Vec2) {
        this._coord = cr;
    }
}

这样写就不行:

const { ccclass, property } = cc._decorator;

@ccclass
export default class NewClass extends cc.Component {
    _coord: cc.Vec2 = null;
    @property(cc.Vec2)
    get coord(): cc.Vec2 {
        return this._coord;
    }
    set coord(cr: cc.Vec2) {
        let oldCoord = this._coord.clone(); //这
        this._coord = cr;
    }
}

在Creator中点Create 创建不了属性。
image

这样不会报错吗?this._coord 可能为 null, clone 会有问题

谢谢。。·111111

该主题在最后一个回复创建后14天后自动关闭。不再允许新的回复。