Просмотр исходного кода

fix: Cocos游戏onCreate调用延后问题

DoggyZhang 11 месяцев назад
Родитель
Сommit
696fc908df

+ 5 - 5
app/src/main/java/com/adealink/weparty/cocosgame/BaseCocosWebGameFragment.kt

@@ -75,11 +75,6 @@ abstract class BaseCocosWebGameFragment<VM : BaseCocosWebGameViewModel<*, *, *,
     override fun initViews() {
         super.initViews()
         val contentViewBinding = contentView()
-        onCocosGameViewCreated(contentViewBinding)
-        if (!AppBaseInfo.isRelease) {
-            // DEBUG包打印游戏路径
-            showToast("DEBUG: gameCode:${cocosGame()}, gameUrl:${gameUrl()}")
-        }
         fixSafeView()
         cocosViewModel.onCreate()
         cocosViewModel.initGame(
@@ -88,6 +83,11 @@ abstract class BaseCocosWebGameFragment<VM : BaseCocosWebGameViewModel<*, *, *,
             InitGameData(cocosGame(), 58.dp())
         )
         loadUrlAfterViewCreated()
+        onCocosGameViewCreated(contentViewBinding)
+        if (!AppBaseInfo.isRelease) {
+            // DEBUG包打印游戏路径
+            showToast("DEBUG: gameCode:${cocosGame()}, gameUrl:${gameUrl()}")
+        }
     }
 
     open fun fixSafeView() {