To those who have tested GameActivity on Unity 2023 here… did you experience a decrease on the ANR’s ?
I’m thinking on migrating from 2022.3.21 to 2023 to test this but I’d like to have a bit more insight before pushing it. Thanks in advance
I only have tested in one game and no decreased nothing my ANR
Damn. Did you faced a lot of incompatibilities with 3d party plugins?
Anybody else wants to share or knows when to find more info about the effectivity of this?
I only use i2.loc and hmm dotween and i think nothing more so no problems with plugins (juanito? xD)
When selecting the entry point of GameActivity, the InputSystem stops working
We have tests which say it should be working, can you elaborate what’s not working exactly?
Unity 6000.0.5f1 - for a long time I could not understand why the Enhanced Touch mobile control did not work in my project. I changed all possible settings, and only changing GameActivity to Activity solved the problem.
Could you please report a bug with repro project attached please? Thank you
@Tomas1856
We are developing an Android app and embedding Unity As A Library, using Unity6.
We would like to use Unity with Jetpack Compose, so basically instantiating the UnityPlayer manually (not through an Activity like UnityPlayerActivity or UnityPlayerGameActivity), and adding its FrameLayout in an AndroidView, something like:
@Composable
fun UnityView() {
val context = LocalContext.current
val lifecycleOwner = LocalLifecycleOwner.current
val unityPlayer = remember { UnityPlayerForActivityOrService(context) }
DisposableEffect(lifecycleOwner) {
val observer = LifecycleEventObserver { _, event ->
when (event) {
Lifecycle.Event.ON_START -> {
unityPlayer.onStart()
}
Lifecycle.Event.ON_RESUME -> {
unityPlayer.onResume()
unityPlayer.windowFocusChanged(true)
}
Lifecycle.Event.ON_PAUSE -> {
unityPlayer.windowFocusChanged(false)
unityPlayer.onPause()
}
Lifecycle.Event.ON_DESTROY -> {
unityPlayer.destroy()
}
Lifecycle.Event.ON_STOP -> {
unityPlayer.onStop()
}
else -> { }
}
}
lifecycleOwner.lifecycle.addObserver(observer)
onDispose {
lifecycleOwner.lifecycle.removeObserver(observer)
unityPlayer.destroy()
}
}
AndroidView(
factory = {
val frameLayout = FrameLayout(context).apply {
addView(unityPlayer.frameLayout)
unityPlayer.frameLayout.requestFocus()
unityPlayer.frameLayout
}
frameLayout
},
update = { layout ->
layout.requestFocus()
}
)
}
This works well with UnityPlayerForActivityOrService, but I cannot find a way to make it work with UnityPlayerForGameActivity.
class UnityPlayerManager : IUnityPlayerLifecycleEvents, IUnityPermissionRequestSupport, IUnityPlayerSupport, SurfaceHolder.Callback {
fun getUnityPlayer(): UnityPlayer {
this.unityPlayer = UnityPlayerForGameActivity((currentContext as Activity), frameLayout, surfaceView, this)
onStart()
onResume()
onWindowFocusChanged(true)
}
override fun surfaceCreated(p0: SurfaceHolder) {
// What goes here?
}
override fun surfaceChanged(p0: SurfaceHolder, p1: Int, p2: Int, p3: Int) {
// What goes here?
}
override fun surfaceDestroyed(p0: SurfaceHolder) {
// What goes here?
}
}
This works and Unity launches as intended, but it never renders so all we see is a white screen.
I believe this is because GameActivity ultimately calls some native methods like
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
if (!this.mDestroyed) {
this.mCurSurfaceHolder = holder;
this.onSurfaceChangedNative(this.mNativeHandle, holder.getSurface(), format, width, height);
}
}
which we cannot call from our Manager.
Do you happen to know if there is a way to avoid using GameActivity but still embed Unity as a Library in an Android app?