show_copy_scene.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { _decorator, Component, EditBox, Node } from 'cc';
  2. import { tools } from '../tools';
  3. const { ccclass, property } = _decorator;
  4. @ccclass('show_copy_scene')
  5. export class show_copy_scene extends Component {
  6. @property(Node) btn_sure:Node = null;
  7. @property(Node) btn_cancel:Node = null;
  8. @property(Node) editBox_scene_name:Node = null;
  9. private m_sure_callback:Function = null;
  10. start() {
  11. this.btn_sure.on(Node.EventType.TOUCH_END, ()=> {
  12. if(this.m_sure_callback != null) {
  13. let string = tools.trimLeftAndRightblank(this.editBox_scene_name.getComponent(EditBox).string)
  14. this.editBox_scene_name.getComponent(EditBox).string = string
  15. if(string=='') {
  16. return tools.showToast('请输入场景名称')
  17. }
  18. this.m_sure_callback(string,this)
  19. }
  20. },this)
  21. this.btn_cancel.on(Node.EventType.TOUCH_END, ()=> {
  22. this.close()
  23. },this)
  24. }
  25. initView(scene_name:string, sure_callback:Function) {
  26. this.m_sure_callback = sure_callback
  27. this.editBox_scene_name.getComponent(EditBox).string = scene_name
  28. }
  29. close() {
  30. this.node.removeFromParent()
  31. }
  32. }