Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unity 2023 & Unity 6000 breaking changes on Android. #839

Closed
timbotimbo opened this issue Jul 9, 2023 · 2 comments
Closed

Unity 2023 & Unity 6000 breaking changes on Android. #839

timbotimbo opened this issue Jul 9, 2023 · 2 comments
Labels
android This issue is specific to the Android Platform. unity breaking change

Comments

@timbotimbo
Copy link
Collaborator

timbotimbo commented Jul 9, 2023

Describe the bug

Unity 2023 changed some Android classes, which cause compile errors with all plugin versions up to 2022.2.x.
This makes Unity 2023 incompatible with the android version of this plugin.

In the 2023.1.0 changelog:

Android: Modified FrameLayout so you can call getFrameLayout function on UnityPlayer instance if you need access to frame layout. UnityPlayer/UnityPlayerForActivityOrService no longer derives from FrameLayout.

This fork was linked on Discord, which is supposed to handle these changes.
https://github.com/ritolika/flutter-unity-view-widget/tree/Unity-2023.1

TODO

There are 2 choices:

  1. Figure out a way to support both 2023 and 2019-2022 using the same plugin
  2. Split the plugin in 2 branches: Pre-2023 and 2023+.

I hope that we can somehow achieve option 1, but I don't know how feasible that is.

Errors

Here are some of the compilation errors you'll get when you try to build it

Compile errors (expand this)
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\CustomUnityPlayer.kt: (13, 1): Class 'CustomUnityPlayer' is not abstract and does not implement abstract base class member public abstract fun setMainSurfaceViewAspectRatio(p0: Float): Unit defined in com.unity3d.player.UnityPlayer
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\CustomUnityPlayer.kt: (13, 1): CustomUnityPlayer inherits invisible abstract members: public/*package*/ abstract fun handleFocus(p0: Boolean): Boolean defined in com.unity3d.player.UnityPlayer, public/*package*/ abstract fun getGfxView(): View! defined in com.unity3d.player.UnityPlayer, public/*package*/ abstract fun onOrientationChanged(p0: Int, p1: Int): Unit defined in com.unity3d.player.UnityPlayer, public/*package*/ abstract fun cleanupResourcesForDestroy(): Unit defined in com.unity3d.player.UnityPlayer
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\CustomUnityPlayer.kt: (13, 102): Type mismatch: inferred type is IUnityPlayerLifecycleEvents? but UnityPlayer.h! was expected
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\CustomUnityPlayer.kt: (13, 105): No value passed for parameter 'p2'
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\CustomUnityPlayer.kt: (19, 5): 'onConfigurationChanged' overrides nothing
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\CustomUnityPlayer.kt: (21, 15): Unresolved 
reference: onConfigurationChanged
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\CustomUnityPlayer.kt: (24, 5): 'onAttachedToWindow' overrides nothing
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\CustomUnityPlayer.kt: (26, 15): Unresolved 
reference: onAttachedToWindow
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\CustomUnityPlayer.kt: (32, 5): 'onDetachedFromWindow' overrides nothing
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\CustomUnityPlayer.kt: (36, 15): Unresolved 
reference: onDetachedFromWindow
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\CustomUnityPlayer.kt: (39, 5): 'dispatchTouchEvent' overrides nothing
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\CustomUnityPlayer.kt: (41, 22): Unresolved 
reference: dispatchTouchEvent
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\CustomUnityPlayer.kt: (45, 5): 'onTouchEvent' overrides nothing
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\CustomUnityPlayer.kt: (49, 22): Unresolved 
reference: onTouchEvent
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\FlutterUnityWidgetController.kt: (337, 44): Unresolved reference: parent
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\FlutterUnityWidgetController.kt: (338, 45): Unresolved reference: parent
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\FlutterUnityWidgetController.kt: (338, 77): Type mismatch: inferred type is CustomUnityPlayer? but View! was expected
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\FlutterUnityWidgetController.kt: (342, 44): Unresolved reference: z
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\FlutterUnityWidgetController.kt: (359, 44): Unresolved reference: parent
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\OverrideUnityActivity.kt: (45, 23): Unresolved reference: lowMemory
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\UnityPlayerUtils.kt: (38, 64): Unresolved reference: requestFocus
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\UnityPlayerUtils.kt: (56, 31): Unresolved reference: bringToFront
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\UnityPlayerUtils.kt: (57, 31): Unresolved reference: requestLayout
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\UnityPlayerUtils.kt: (58, 31): Unresolved reference: invalidate
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\UnityPlayerUtils.kt: (177, 31): Unresolved 
reference: parent
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\UnityPlayerUtils.kt: (179, 65): Type mismatch: inferred type is CustomUnityPlayer? but View! was expected
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\UnityPlayerUtils.kt: (196, 19): None of the following functions can be called with the arguments supplied:
public open fun addView(p0: View!, p1: ViewGroup.LayoutParams!): Unit defined in android.view.ViewGroup
public open fun addView(p0: View!, p1: Int): Unit defined in android.view.ViewGroup
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\UnityPlayerUtils.kt: (203, 31): Unresolved 
reference: parent
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\UnityPlayerUtils.kt: (204, 32): Unresolved 
reference: parent
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\UnityPlayerUtils.kt: (204, 64): Type mismatch: inferred type is CustomUnityPlayer? but View! was expected
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\UnityPlayerUtils.kt: (207, 31): Unresolved 
reference: z
e: C:\<path>\unity_widget\android\src\main\kotlin\com\xraph\plugin\flutter_unity_widget\UnityPlayerUtils.kt: (210, 39): Type mismatch: inferred type is CustomUnityPlayer? but View! was expected

To Reproduce

Steps to reproduce the behavior:

  1. Export the example project using Unity 2023.1.x
  2. Run or build the Flutter project for Android.
@timbotimbo timbotimbo added android This issue is specific to the Android Platform. unity breaking change labels Jul 9, 2023
@k0uhe1D
Copy link

k0uhe1D commented Jul 10, 2023

I've briefly researched the changes in Unity Android that occur in Unity 2023 and later, and I'd like to share my findings.

@timbotimbo timbotimbo changed the title Unity 2023 breaking changes on Android. Unity 2023 & Unity 6 breaking changes on Android. Jun 25, 2024
@timbotimbo timbotimbo changed the title Unity 2023 & Unity 6 breaking changes on Android. Unity 2023 & Unity 6000 breaking changes on Android. Jul 2, 2024
@timbotimbo
Copy link
Collaborator Author

timbotimbo commented Jul 2, 2024

I added a branch to test an alpha implementation for Unity 6.
Check #967 for instructions.

Given that 6 is actually 2023.3, I'm skipping 2023.1 and 2023.2.

Since Unity changed their classes, I decided on a separate verion that isn't backwards compatible. The only alternative is using a lot of reflection to pick the correct classes, which won't be good for maintenance and performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android This issue is specific to the Android Platform. unity breaking change
Projects
None yet
Development

No branches or pull requests

2 participants