-
Notifications
You must be signed in to change notification settings - Fork 7
[Draft] Android compatibility for Unity 6000.x #24
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
Conversation
… references to 2022.
…importing the 2022_3_android package.
…yPlayer no longer extending a FrameLayout.
…e Gradle 8 namespace replace.
Because I had to copy some folders, merging/rebasing on main wasn't as clean as I hoped. So for now I've recreated this in another branch, based on the latest main. I got the example fully functional, but it needs some more testing. |
Your PRs #36 and #37 are now merged into main and published on pub.dev as flutter_embed_unity 1.2.7 and flutter_embed_unity_2022_3_android 1.1.3. I've also updated the example projects to Kotlin gradle DSL and to support Flutter 3.29 out of the box, including an extra step in the Unity exporter script to remove ndkPath from unityLibrary/build.gradle. So, hopefully this is a better base for merging in your new Unity 6000 branch. |
Thank you, I have created a branch called feat/unity6 and merged your android_Unity_6000 branch from your fork. It merged without any problems. I'll start some testing and maybe start adding a platform package for ios too. |
I believe unity 6000 ios could work with the 2022.3 version, without any changes. After the merge you will be missing 2 changes in the 6000 folders.
|
The only thing I wasn't 100% sure about yet is whether Besides that I think everything functions like the 2022.3 version. |
Ah I see, thank you. That's great, I'll not add a separate package either.
I'll add these, thank you. One question: the app-facing package uses the flutter:
plugin:
platforms:
android:
default_package: flutter_embed_unity_2022_3_android
ios:
default_package: flutter_embed_unity_2022_3_ios In the flutter_embed_unity_6000_0_android example app (and in consumer apps in general) how do you actually override this to specify that the 6000_0 package should be used instead of the 2022_3 package? I see you have added it as a dependency in the example's pubspec.yaml like this: dependencies:
flutter:
sdk: flutter
flutter_embed_unity_6000_0_android: ^1.1.2-beta.2
flutter_embed_unity: ^1.2.6-beta.2 (Obviously during development these would be changed to the local paths for those packages). Is that all you need to do? Does Flutter auto-magically figure out that, because you have added a dependency which implements a platform for a federated plugin, that this should override the default? I can't find any documentation which explains this, wondered if you had any insight. Thanks |
If you import a package that implements the same platform interface, a direct dependency should override defaults. Here in Non-endorsed federated plugin they mention
I can actually directly run the example with the following, so you can even test without local paths. flutter_embed_unity_6000_0_android:
git:
url: https://github.com/learntoflutter/flutter_embed_unity.git
ref: feat/unity6
path: flutter_embed_unity_6000_0_android/
flutter_embed_unity: ^1.2.6-beta.2 This shoud be simple for documentation and install instructions while multiple Unity versions are supported. for 2022 (default for now) flutter_embed_unity: ... for 6000: flutter_embed_unity_6000_0_android: .. # add android override
flutter_embed_unity: ... I imagine after a while (months/ year?) this turns into 6000 as default and 2022 with an override. |
Thank you, I somehow missed that part in the docs about non-endorsed plugin implementations. This is great, I was hoping it would be a straight-forward configuration change. I agree, for some amount of time, using 6000 should be opt-in using an override, and at some point in the future it should become the default. |
This is now published as a pre-release for testing: dependencies:
flutter_embed_unity: ^1.3.0-beta.1
flutter_embed_unity_6000_0_android: ^1.2.1-beta.1 Thanks so much for your contribution! |
This PR is not meant to be merged in the current state
I wanted to test Unity 6000 for #21, and I might as well share what I changed.
Description
While for iOS there is hardly any difference in newer Unity versions, Android had some breaking changes in 2023.
Given that Unity 2023.3 turned into 6000, we can skip 2023 as the the next LTS will be 6000.x.
This PR is a proof of concept for supporting Android on Unity 6000.x.
Hopefully this will make an eventual update easier when 6000 enters LTS.
All basic functionality is restored for now, as all example functionality seems to work using Unity 6000.0.8 and Flutter 3.22.
Changes in the Unity 6000 export
Unity 2023+ makes the
UnityPlayer
class abstract and exposesUnityPlayerForServiceOrActivity
andUnityPlayerForGameActivity
instead.UnityPlayer no longer extends
FrameLayout
which breaks some overrides.The exported
UnityLibrary/build.gradle
now imports a gradle file from a.../shared
folder.strings.xml with
game_view_content_description
is now located in unityLibrary instead of launcher. (6000.0.22+)Gradle versions are updated to 8.x
Java is updated to 17
Updates in this PR
UnityPlayerForServiceOrActivity
instead ofUnityPlayer
UnityView.kt
a custom instance, to handle the touch input fix indispatchTouchEvent
instead of in UnitPlayer'sonTouchEvent
.shared
folder in the android exporter.TODO
UnityPlayerSingleton can no longer have an override for
onWindowVisibilityChanged
.I've temporarily placed this function in the CustomFrameLayout that now handles the touch input fix.
However this will likely miss some instances where Unity is removed and reattached.
Maybe this can be done using a listener on unity's framelayout instead.
Cleanup & documentation
Alternatives
This react-native plugin has found a way of supporting both UnityPlayer and UnityPlayerForServiceOrActivity using reflection.
Although a nice concept, I think this will make maintenance harder and reflection won't help with performance.