diff --git a/android/src/main/kotlin/com/xraph/plugin/flutter_unity_widget/FlutterUnityWidgetController.kt b/android/src/main/kotlin/com/xraph/plugin/flutter_unity_widget/FlutterUnityWidgetController.kt index a54132f8e..c9f272bfe 100755 --- a/android/src/main/kotlin/com/xraph/plugin/flutter_unity_widget/FlutterUnityWidgetController.kt +++ b/android/src/main/kotlin/com/xraph/plugin/flutter_unity_widget/FlutterUnityWidgetController.kt @@ -285,10 +285,12 @@ class FlutterUnityWidgetController( private fun createPlayer() { try { if (UnityPlayerUtils.activity != null) { + loadedCallbackPending = true UnityPlayerUtils.createUnityPlayer( this, object : OnCreateUnityViewCallback { override fun onReady() { // attach unity to controller attachToView() + loadedCallbackPending = false if (methodChannelResult != null) { methodChannelResult!!.success(true) @@ -298,6 +300,7 @@ class FlutterUnityWidgetController( }) } } catch (e: Exception) { + loadedCallbackPending = false if (methodChannelResult != null) { methodChannelResult!!.error("FLUTTER_UNITY_WIDGET", e.message, e) methodChannelResult!!.success(false) @@ -372,7 +375,6 @@ class FlutterUnityWidgetController( return } - loadedCallbackPending = false postFrameCallback { postFrameCallback { view.invalidate()