cocos 在onload setposition 无效
在 pveUI 加載 `mainstageUI` prefab 生成出來後掛載在 scrollview content 底下, 且`mainstageUI` 上面已經掛好了腳本 mainstageUIPanel, 奇怪的是 mainstageUIPanel 設置更新 pot position 卻無效。
一開始以為是 scrollview 還是其他因素造成, 後來測試許久發現是 mainstageUIPanel 內的都無效, 最終多方查看發現可能有一點奇妙的就是 mainstageUIPanel 初始化是寫在 onLoad 內的, 把位置刷新改到 start 再執行發現可以了。
可能是因為 prefab 生成掛載執行流程是 onload -> start, 在這過程中 widget 會再次重製, 所以才會無效, 也可以看看論壇說的
ref. https://forum.cocos.org/t/topic/137332
留言
張貼留言