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
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,20 @@ class _MyAppState extends State<MyApp> {
> commandLineArgs.add("--profiler-report")
> commandLineArgs.add("--profiler-output-file=" + workingDir + "/build/il2cpp_"+ abi + "_" + configuration + "/il2cpp_conv.traceevents")

### Web GL

> If you develop and ship Flutter with Unity WebGL then you will first notice, that stacked Widgets over your UnityWidget are not tappable!

This is actually a Flutter related Issue (See: https://github.com/flutter/flutter/issues/72273).

To solve this, Flutter-Team already got a solution for this. Use: [PointerInterceptor](https://pub.dev/packages/pointer_interceptor)!

Example usage:

![PointerInterceptor](https://github.com/juicycleff/flutter-unity-view-widget/blob/master/files/PointerInterceptor.png?raw=true)

Note: We already integrated this into our [Examples](/example/lib/screens/) in the `/example` folder.


#### Sponsors

Expand Down
163 changes: 83 additions & 80 deletions example/lib/screens/api_screen.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_unity_widget/flutter_unity_widget.dart';
import 'package:pointer_interceptor/pointer_interceptor.dart';

class ApiScreen extends StatefulWidget {
ApiScreen({Key key}) : super(key: key);
Expand Down Expand Up @@ -47,88 +48,90 @@ class _ApiScreenState extends State<ApiScreen> {
webUrl: 'http://localhost:6080',
),
),
Positioned(
bottom: 20,
left: 20,
right: 20,
child: Card(
elevation: 10,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 20),
child: Text("Rotation speed:"),
),
Slider(
onChanged: (value) {
setState(() {
_sliderValue = value;
});
setRotationSpeed(value.toString());
},
value: _sliderValue,
min: 0,
max: 20,
),
FittedBox(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
MaterialButton(
onPressed: () {
_unityWidgetController.quit();
},
child: Text("Quit"),
),
MaterialButton(
onPressed: () {
_unityWidgetController.create();
},
child: Text("Create"),
),
MaterialButton(
onPressed: () {
_unityWidgetController.pause();
},
child: Text("Pause"),
),
MaterialButton(
onPressed: () {
_unityWidgetController.resume();
},
child: Text("Resume"),
),
],
PointerInterceptor(
child: Positioned(
bottom: 20,
left: 20,
right: 20,
child: Card(
elevation: 10,
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 20),
child: Text("Rotation speed:"),
),
),
FittedBox(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
MaterialButton(
onPressed: () async {
await _unityWidgetController
.openInNativeProcess();
},
child: Text("Open Native"),
),
MaterialButton(
onPressed: () {
_unityWidgetController.unload();
},
child: Text("Unload"),
),
MaterialButton(
onPressed: () {
_unityWidgetController.quit();
},
child: Text("Silent Quit"),
),
],
Slider(
onChanged: (value) {
setState(() {
_sliderValue = value;
});
setRotationSpeed(value.toString());
},
value: _sliderValue,
min: 0,
max: 20,
),
),
],
FittedBox(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
MaterialButton(
onPressed: () {
_unityWidgetController.quit();
},
child: Text("Quit"),
),
MaterialButton(
onPressed: () {
_unityWidgetController.create();
},
child: Text("Create"),
),
MaterialButton(
onPressed: () {
_unityWidgetController.pause();
},
child: Text("Pause"),
),
MaterialButton(
onPressed: () {
_unityWidgetController.resume();
},
child: Text("Resume"),
),
],
),
),
FittedBox(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
MaterialButton(
onPressed: () async {
await _unityWidgetController
.openInNativeProcess();
},
child: Text("Open Native"),
),
MaterialButton(
onPressed: () {
_unityWidgetController.unload();
},
child: Text("Unload"),
),
MaterialButton(
onPressed: () {
_unityWidgetController.quit();
},
child: Text("Silent Quit"),
),
],
),
),
],
),
),
),
),
Expand Down
51 changes: 27 additions & 24 deletions example/lib/screens/loader_screen.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_unity_widget/flutter_unity_widget.dart';
import 'package:pointer_interceptor/pointer_interceptor.dart';

class LoaderScreen extends StatefulWidget {
LoaderScreen({Key key}) : super(key: key);
Expand Down Expand Up @@ -37,30 +38,32 @@ class _LoaderScreenState extends State<LoaderScreen> {
webUrl: 'http://localhost:6080',
useAndroidViewSurface: true,
),
Positioned(
bottom: 20,
left: 20,
right: 20,
child: Card(
elevation: 10,
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 20),
child: Text("Rotation speed:"),
),
Slider(
onChanged: (value) {
setState(() {
_sliderValue = value;
});
setRotationSpeed(value.toString());
},
value: _sliderValue,
min: 0,
max: 20,
),
],
PointerInterceptor(
child: Positioned(
bottom: 20,
left: 20,
right: 20,
child: Card(
elevation: 10,
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 20),
child: Text("Rotation speed:"),
),
Slider(
onChanged: (value) {
setState(() {
_sliderValue = value;
});
setRotationSpeed(value.toString());
},
value: _sliderValue,
min: 0,
max: 20,
),
],
),
),
),
),
Expand Down
21 changes: 12 additions & 9 deletions example/lib/screens/no_interaction_screen.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_unity_widget/flutter_unity_widget.dart';
import 'package:pointer_interceptor/pointer_interceptor.dart';

class NoInteractionScreen extends StatefulWidget {
NoInteractionScreen({Key key}) : super(key: key);
Expand Down Expand Up @@ -48,15 +49,17 @@ class _NoInteractionScreenState extends State<NoInteractionScreen> {
useAndroidViewSurface: true,
borderRadius: BorderRadius.all(Radius.circular(70)),
),
Positioned(
bottom: 20,
left: 20,
right: 20,
child: ElevatedButton(
onPressed: () {
Navigator.of(context).pushNamed('/simple');
},
child: Text('Switch Flutter Screen'),
PointerInterceptor(
child: Positioned(
bottom: 20,
left: 20,
right: 20,
child: ElevatedButton(
onPressed: () {
Navigator.of(context).pushNamed('/simple');
},
child: Text('Switch Flutter Screen'),
),
),
),
],
Expand Down
83 changes: 43 additions & 40 deletions example/lib/screens/orientation_screen.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_unity_widget/flutter_unity_widget.dart';
import 'package:pointer_interceptor/pointer_interceptor.dart';

class OrientationScreen extends StatefulWidget {
OrientationScreen({Key key}) : super(key: key);
Expand Down Expand Up @@ -38,46 +39,48 @@ class _LoaderScreenState extends State<OrientationScreen> {
webUrl: 'http://localhost:6080',
useAndroidViewSurface: true,
),
Positioned(
bottom: 20,
left: 20,
right: 20,
child: Card(
elevation: 10,
child: Column(
children: <Widget>[
ElevatedButton(
onPressed: () {
if (MediaQuery.of(context).orientation ==
Orientation.portrait) {
SystemChrome.setPreferredOrientations([
DeviceOrientation.landscapeLeft,
DeviceOrientation.landscapeRight
]);
} else if (MediaQuery.of(context).orientation ==
Orientation.landscape) {
SystemChrome.setPreferredOrientations(
[DeviceOrientation.portraitUp]);
}
},
child: Text("Change Orientation"),
),
Padding(
padding: const EdgeInsets.only(top: 20),
child: Text("Rotation speed:"),
),
Slider(
onChanged: (value) {
setState(() {
_sliderValue = value;
});
setRotationSpeed(value.toString());
},
value: _sliderValue,
min: 0,
max: 20,
),
],
PointerInterceptor(
child: Positioned(
bottom: 20,
left: 20,
right: 20,
child: Card(
elevation: 10,
child: Column(
children: <Widget>[
ElevatedButton(
onPressed: () {
if (MediaQuery.of(context).orientation ==
Orientation.portrait) {
SystemChrome.setPreferredOrientations([
DeviceOrientation.landscapeLeft,
DeviceOrientation.landscapeRight
]);
} else if (MediaQuery.of(context).orientation ==
Orientation.landscape) {
SystemChrome.setPreferredOrientations(
[DeviceOrientation.portraitUp]);
}
},
child: Text("Change Orientation"),
),
Padding(
padding: const EdgeInsets.only(top: 20),
child: Text("Rotation speed:"),
),
Slider(
onChanged: (value) {
setState(() {
_sliderValue = value;
});
setRotationSpeed(value.toString());
},
value: _sliderValue,
min: 0,
max: 20,
),
],
),
),
),
),
Expand Down
Loading