show_select_z_index.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { _decorator, Component, instantiate, Node, Prefab } from 'cc';
  2. import { config } from '../../config';
  3. import { show_select_z_index_item } from './show_select_z_index_item';
  4. const { ccclass, property } = _decorator;
  5. @ccclass('show_select_z_index')
  6. export class show_select_z_index extends Component {
  7. protected m_call_back = null;
  8. @property(Prefab) item_prefab:Prefab = null;
  9. @property(Node) content:Node = null;
  10. public show(call){
  11. this.m_call_back = call;
  12. config.Zindex_type_map.forEach((v,k)=>{
  13. let item = instantiate(this.item_prefab)
  14. item.parent = this.content;
  15. item.getComponent(show_select_z_index_item).initView(k,v,this.onItemClick.bind(this))
  16. })
  17. }
  18. public showDir(call){
  19. this.m_call_back = call;
  20. config.widget_scale_dir_map.forEach((v,k)=>{
  21. let item = instantiate(this.item_prefab)
  22. item.parent = this.content;
  23. item.getComponent(show_select_z_index_item).initView(k,v,this.onItemClick.bind(this))
  24. })
  25. }
  26. close(){
  27. this.node.removeFromParent()
  28. }
  29. onItemClick(z:number){
  30. if(this.m_call_back!=null){
  31. this.m_call_back(z)
  32. }
  33. this.close()
  34. }
  35. }