Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 4.0.1

* Allow optional use of AndroidView over PlatformViewLink on android

## 4.0.0

* Stable release for v4
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ project(":unityLibrary").projectDir = file("./unityLibrary")
```
4. If you use `minifyEnabled true` and need to use UnityMessage in Flutter, please add proguard content below:
```
-keep class com.xraph.plugins.** {*;}
-keep class com.xraph.plugin.** {*;}
```
5. If you want unity in it's own activity as an alternative, just add this to your app `AndroidManifest.xml` file
```xml
Expand Down
21 changes: 16 additions & 5 deletions lib/src/device_method.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,31 @@ class MethodChannelUnityViewFlutter extends UnityViewFlutterPlatform {

@override
Widget buildView(
Map<String, dynamic> creationParams,
Set<Factory<OneSequenceGestureRecognizer>> gestureRecognizers,
PlatformViewCreatedCallback onPlatformViewCreated,
) {
Map<String, dynamic> creationParams,
Set<Factory<OneSequenceGestureRecognizer>> gestureRecognizers,
PlatformViewCreatedCallback onPlatformViewCreated,
bool useAndroidView) {
final String _viewType = 'plugin.xraph.com/unity_view';

if (defaultTargetPlatform == TargetPlatform.android) {
if (useAndroidView) {
return AndroidView(
viewType: _viewType,
onPlatformViewCreated: onPlatformViewCreated,
gestureRecognizers: gestureRecognizers,
hitTestBehavior: PlatformViewHitTestBehavior.opaque,
creationParams: creationParams,
creationParamsCodec: StandardMessageCodec(),
);
}

return PlatformViewLink(
viewType: _viewType,
surfaceFactory:
(BuildContext context, PlatformViewController controller) {
return AndroidViewSurface(
controller: controller,
gestureRecognizers: const <Factory<OneSequenceGestureRecognizer>>{},
gestureRecognizers: gestureRecognizers,
hitTestBehavior: PlatformViewHitTestBehavior.opaque,
);
},
Expand Down
12 changes: 8 additions & 4 deletions lib/src/unity_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ class UnityWidget extends StatefulWidget {
/// This flag enables placeholder widget
final bool enablePlaceholder;

/// This flag allows you use AndroidView instead of PlatformViewLink for android
final bool useAndroidView;

/// This is just a helper to render a placeholder widget
final Widget placeholder;

Expand All @@ -33,6 +36,7 @@ class UnityWidget extends StatefulWidget {
this.onUnityUnloaded,
this.gestureRecognizers,
this.placeholder,
this.useAndroidView = false,
this.onUnitySceneLoaded,
});

Expand Down Expand Up @@ -68,10 +72,10 @@ class _UnityWidgetState extends State<UnityWidget> {
}

return _unityViewFlutterPlatform.buildView(
creationParams,
widget.gestureRecognizers,
onPlatformViewCreated,
);
creationParams,
widget.gestureRecognizers,
onPlatformViewCreated,
widget.useAndroidView);
}

Future<void> onPlatformViewCreated(int id) async {
Expand Down
3 changes: 2 additions & 1 deletion lib/src/unity_view_flutter_platform.dart
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ abstract class UnityViewFlutterPlatform extends PlatformInterface {
Widget buildView(
Map<String, dynamic> creationParams,
Set<Factory<OneSequenceGestureRecognizer>> gestureRecognizers,
PlatformViewCreatedCallback onPlatformViewCreated) {
PlatformViewCreatedCallback onPlatformViewCreated,
bool useAndroidView) {
throw UnimplementedError('buildView() has not been implemented.');
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: flutter_unity_widget
description: Flutter Unity 3D widget for embedding Unity game scenes in flutter. This library now supports Unity as a Library.
version: 4.0.0
version: 4.0.1
#authors:
# - Rex Raphael <rex.raphael@outlook.com>
# - Thomas Stockx <thomas@stockxit.com>
Expand Down