-
Notifications
You must be signed in to change notification settings - Fork 530
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Android] Fix Unity plugins using the AndroidJavaProxy. (mUnityPlayer…
… error) (#908) * Fix AndroidJavaProxy error: assign mUnityPlayer in the MainActivity. * Add MainActivity modifications to the readme. * Adjust MainAcitivty modification documentation. * Update some version numbers
- Loading branch information
1 parent
4075d91
commit ecee37d
Showing
5 changed files
with
116 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
android/src/main/kotlin/com/xraph/plugin/flutter_unity_widget/FlutterUnityActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.xraph.plugin.flutter_unity_widget | ||
|
||
import io.flutter.embedding.android.FlutterActivity | ||
|
||
/* | ||
The following Unity versions expect the mUnityPlayer property on the main activity: | ||
- 2020.3.46 or higher | ||
- 2021.3.19 - 2021.3.20 | ||
- 2022.2.4 - 2022.3.18 | ||
Unity will function without it, but many Unity plugins (like ARFoundation) will not. | ||
Implement FlutterUnityActivity or the interface to fix these plugins. | ||
https://github.com/juicycleff/flutter-unity-view-widget/pull/908 | ||
*/ | ||
|
||
open class FlutterUnityActivity: FlutterActivity() { | ||
@JvmField | ||
var mUnityPlayer: java.lang.Object? = null; | ||
} | ||
|
||
|
||
/* | ||
A function that is called when initializing Unity. | ||
Expected use is to set a mUnityPlayer property, just as defined in FlutterUnityActivity above. | ||
*/ | ||
interface IFlutterUnityActivity { | ||
fun setUnityPlayer(unityPlayer: java.lang.Object?) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 18 additions & 2 deletions
20
...android/app/src/main/kotlin/com/xraph/plugin/flutter_unity_widget_example/MainActivity.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,22 @@ | ||
package com.xraph.plugin.flutter_unity_widget_example | ||
|
||
import io.flutter.embedding.android.FlutterActivity | ||
import com.xraph.plugin.flutter_unity_widget.FlutterUnityActivity; | ||
|
||
class MainActivity: FlutterActivity() { | ||
class MainActivity: FlutterUnityActivity() { | ||
|
||
} | ||
|
||
|
||
// If you can't inherit FlutterUnityActivity directly, use the interface like this: | ||
/* | ||
import com.xraph.plugin.flutter_unity_widget.IFlutterUnityActivity; | ||
class ActivityExample: SomeActivity(), IFlutterUnityActivity { | ||
@JvmField | ||
var mUnityPlayer: java.lang.Object? = null; | ||
override fun setUnityPlayer(unityPlayer: java.lang.Object?) { | ||
mUnityPlayer = unityPlayer; | ||
} | ||
} | ||
*/ |