NativeAd.ts 592 Bytes
import AdManager, { ADPoint } from "../sdk/AdManager";

export default class NativeAd extends Laya.Script {
    /** @prop {name:point, tips:"广告点", type:String}*/
    public point: ADPoint;

    constructor() { super(); }

    onEnable(): void {
        let globalPoint = this.item.localToGlobal(Laya.Point.EMPTY, true);
        AdManager.I.showNativeAd(this.point, globalPoint.x, globalPoint.y, this.item.width, this.item.height);
    }

    onDisable(): void {
        AdManager.I.closeAdverDialog();
    }

    private get item(): Laya.View {
        return this.owner as any;
    }
}