toast.ts 382 B

123456789101112131415
  1. import { _decorator, Component, Label, Node } from 'cc';
  2. const { ccclass, property } = _decorator;
  3. @ccclass('toast')
  4. export class toast extends Component {
  5. @property(Node) lab_text:Node = null;
  6. public show(text:string){
  7. this.lab_text.getComponent(Label).string = text;
  8. this.scheduleOnce(()=>{
  9. this.node.removeFromParent()
  10. },1)
  11. }
  12. }