哪里写错了为什么报错?我好迷茫啊!

import { _decorator, Component, Node, Camera, View, Vec3, view, Prefab, geometry, SystemEvent, systemEvent, SystemEventType, EventTouch, Canvas, Touch, Label, UITransform } from ‘cc’;
const { ccclass, property } = _decorator;

@ccclass(‘Text’)
export class Text extends Component {
@property({ type: Label }) readonly label: Label = null!;
@property({ type: Camera }) readonly camera: Camera = null!;

// @property({ type: [Node] }) readonly bg: Node = [];
// @property({ type: [Prefab] }) mapPrefab: Prefab = [];
// @property({ type: Camera }) mainCamera: Camera = null;
// out: Vec3 = new Vec3();
// mapWigth: number = 1244;
// mapHight: number = 1364;
// line1 = [false, false, false, false]
// line2 = [false, false, false, false]
// screenWidth: number = 0;
// screenHigth: number = 0;
private _ray: geometry.Ray = new geometry.Ray();
private _aabb: geometry.AABB = new geometry.AABB();
start() {

}
onEnable() {
    systemEvent.on(SystemEventType.TOUCH_START, this.onTouchStart, this);
}
onTouchStart(touch: Touch, event: EventTouch) {
    const uiCamera = this.camera
    const point = touch.getLocation();
    uiCamera.screenPointToRay(point.x, point.y, this._ray);
    const uiTrans = this.label.getComponent(UITransform)!;
    uiTrans.getComputeAABB(this._aabb);
    if (geometry.intersect.rayAABB(this._ray, this._aabb)) {
        this.label.string = '检测成功';
        systemEvent.off(SystemEventType.TOUCH_START, this.onTouchStart, this);
    }
}
onDisable() {
    systemEvent.off(SystemEventType.TOUCH_START, this.onTouchStart, this);
}


效果实现了但是就是报错

好郁闷啊

编辑器上面的camear有挂上去吗,你这个uicamear像是null

为什么你的label只读,你还对他进行设置啊?

07433E3A-0A03-4F1E-9D95-2816CA7FEF30 挂了的

这个嘛copy的代码 没仔细看 但是问题不在这里 还是会报错

算了算了 我是真的菜 我挂了两个组件一个拖了 一个没拖 是我菜了

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