getChildAt报错问题
This commit is contained in:
@@ -58,11 +58,8 @@ export class TrophyRoom extends Laya.Script {
|
||||
console.log(">>>>>>>>>>>>years=", years)
|
||||
ResourceManager.getInstance().loadPrefab(respath.trophy_year_ui_res(), (go: any) => {
|
||||
for (let i = 1; i < years.length; i++) {
|
||||
const obj_year = this.obj_items.getChildAt(i)
|
||||
if (!obj_year) {
|
||||
const prefab = go.create()
|
||||
this.obj_items.addChild(prefab)
|
||||
}
|
||||
const prefab = go.create()
|
||||
this.obj_items.addChild(prefab)
|
||||
}
|
||||
|
||||
ResourceManager.getInstance().loadPrefab(respath.trophy_cell_ui_res(), (go: any) => {
|
||||
@@ -78,13 +75,13 @@ export class TrophyRoom extends Laya.Script {
|
||||
const label = obj_year.getChildByName("year").getChildByName("Label") as Laya.Label
|
||||
label.text = years[i].toString()
|
||||
|
||||
for (let j = 2; j < cellCount + 1; j++) {
|
||||
const prefab = go.create()
|
||||
obj_year.addChild(prefab)
|
||||
}
|
||||
let index = -1
|
||||
for (let j = 1; j < cellCount + 1; j++) {
|
||||
let obj_cell = obj_year.getChildAt(j)
|
||||
if (!obj_cell) {
|
||||
const prefab = go.create()
|
||||
obj_cell = obj_year.addChild(prefab)
|
||||
}
|
||||
const hbox = obj_cell.getChildByName("HBox")
|
||||
for (let k = 0; k < hbox.numChildren; k++) {
|
||||
const unit = hbox.getChildAt(k).getComponent(TrophyUnit)
|
||||
|
||||
Reference in New Issue
Block a user