widget_list.ts 733 B

1234567891011121314151617181920212223
  1. import { _decorator, Component, instantiate, Node, Prefab, ScrollView } from 'cc';
  2. import { config } from '../config';
  3. import { widget_item } from './widget_item';
  4. const { ccclass, property } = _decorator;
  5. @ccclass('widget_list')
  6. export class widget_list extends Component {
  7. @property(Prefab) item_prefab
  8. protected start(): void {
  9. this.initView()
  10. }
  11. public initView(){
  12. config.init()
  13. this.node.getComponent(ScrollView).content.removeAllChildren()
  14. config.Widget_Type.forEach((v,k)=>{
  15. let item:Node = instantiate(this.item_prefab)
  16. item.parent = this.node.getComponent(ScrollView).content
  17. item.getComponent(widget_item).initView(v)
  18. })
  19. }
  20. }