Disabled disposing of the native Unity player. Improved documentation and type annotations.
This commit is contained in:
parent
b2127d9310
commit
c86d50e269
|
@ -25,20 +25,23 @@ node_modules/
|
||||||
|
|
||||||
# Flutter/Dart/Pub related
|
# Flutter/Dart/Pub related
|
||||||
**/doc/api/
|
**/doc/api/
|
||||||
.dart_tool/
|
**/.dart_tool/
|
||||||
.flutter-plugins
|
**/.flutter-plugins
|
||||||
.packages
|
**/.packages
|
||||||
.pub-cache/
|
**/.pub-cache/
|
||||||
.pub/
|
**/.pub/
|
||||||
build/
|
**/build/
|
||||||
|
|
||||||
android/UnityExport/
|
**/android/UnityExport/
|
||||||
|
**/ios/UnityExport/
|
||||||
|
|
||||||
#example/
|
#example/
|
||||||
example/unity/DemoApp/Builds/
|
example/unity/DemoApp/Builds/
|
||||||
example/unity/DemoApp/Library/
|
example/unity/DemoApp/Library/
|
||||||
example/unity/DemoApp/Logs/
|
example/unity/DemoApp/Logs/
|
||||||
example/unity/DemoApp/Temp/
|
example/unity/DemoApp/Temp/
|
||||||
|
example/unity/DemoApp/.vs
|
||||||
|
example/coverage/
|
||||||
|
|
||||||
# Android related
|
# Android related
|
||||||
**/android/**/gradle-wrapper.jar
|
**/android/**/gradle-wrapper.jar
|
||||||
|
@ -49,6 +52,9 @@ example/unity/DemoApp/Temp/
|
||||||
**/android/local.properties
|
**/android/local.properties
|
||||||
**/android/**/GeneratedPluginRegistrant.java
|
**/android/**/GeneratedPluginRegistrant.java
|
||||||
|
|
||||||
|
**/android/key.properties
|
||||||
|
*.jks
|
||||||
|
|
||||||
# iOS/XCode related
|
# iOS/XCode related
|
||||||
**/ios/**/*.mode1v3
|
**/ios/**/*.mode1v3
|
||||||
**/ios/**/*.mode2v3
|
**/ios/**/*.mode2v3
|
||||||
|
@ -74,6 +80,7 @@ example/unity/DemoApp/Temp/
|
||||||
**/ios/Flutter/flutter_assets/
|
**/ios/Flutter/flutter_assets/
|
||||||
**/ios/ServiceDefinitions.json
|
**/ios/ServiceDefinitions.json
|
||||||
**/ios/Runner/GeneratedPluginRegistrant.*
|
**/ios/Runner/GeneratedPluginRegistrant.*
|
||||||
|
**/ios/Flutter/flutter_export_environment.sh
|
||||||
|
|
||||||
# Exceptions to above rules.
|
# Exceptions to above rules.
|
||||||
!**/ios/**/default.mode1v3
|
!**/ios/**/default.mode1v3
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class FlutterUnityView implements PlatformView, MethodChannel.MethodCallH
|
||||||
@Override
|
@Override
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
if (UnityUtils.isUnityReady()) {
|
if (UnityUtils.isUnityReady()) {
|
||||||
UnityUtils.getPlayer().quit();
|
// UnityUtils.getPlayer().quit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"_info":"// This is a generated file; do not edit or check into version control.","dependencyGraph":[{"name":"flutter_unity_widget","dependencies":[]}]}
|
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_unity_widget","path":"/Users/michael/.pub-cache/hosted/pub.dartlang.org/flutter_unity_widget-0.1.6+8/","dependencies":[]}],"android":[{"name":"flutter_unity_widget","path":"/Users/michael/.pub-cache/hosted/pub.dartlang.org/flutter_unity_widget-0.1.6+8/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"flutter_unity_widget","dependencies":[]}],"date_created":"2020-04-05 22:00:19.385164","version":"1.14.6"}
|
|
@ -1,87 +0,0 @@
|
||||||
# Miscellaneous
|
|
||||||
*.class
|
|
||||||
*.lock
|
|
||||||
*.log
|
|
||||||
*.pyc
|
|
||||||
*.swp
|
|
||||||
.DS_Store
|
|
||||||
.atom/
|
|
||||||
.buildlog/
|
|
||||||
.history
|
|
||||||
.svn/
|
|
||||||
|
|
||||||
# IntelliJ related
|
|
||||||
*.iml
|
|
||||||
*.ipr
|
|
||||||
*.iws
|
|
||||||
.idea/
|
|
||||||
|
|
||||||
# Visual Studio Code related
|
|
||||||
.vscode/
|
|
||||||
|
|
||||||
# Flutter/Dart/Pub related
|
|
||||||
**/doc/api/
|
|
||||||
.dart_tool/
|
|
||||||
.flutter-plugins
|
|
||||||
.packages
|
|
||||||
.pub-cache/
|
|
||||||
.pub/
|
|
||||||
build/
|
|
||||||
|
|
||||||
android/UnityExport/
|
|
||||||
ios/UnityExport/
|
|
||||||
unity/DemoApp/.vs
|
|
||||||
|
|
||||||
#example/
|
|
||||||
example/unity/DemoApp/Builds/
|
|
||||||
example/unity/DemoApp/Library/
|
|
||||||
example/unity/DemoApp/Logs/
|
|
||||||
example/unity/DemoApp/Temp/
|
|
||||||
|
|
||||||
# Android related
|
|
||||||
**/android/**/gradle-wrapper.jar
|
|
||||||
**/android/.gradle
|
|
||||||
**/android/captures/
|
|
||||||
**/android/gradlew
|
|
||||||
**/android/gradlew.bat
|
|
||||||
**/android/local.properties
|
|
||||||
**/android/**/GeneratedPluginRegistrant.java
|
|
||||||
**/android/key.properties
|
|
||||||
*.jks
|
|
||||||
|
|
||||||
# iOS/XCode related
|
|
||||||
**/ios/**/*.mode1v3
|
|
||||||
**/ios/**/*.mode2v3
|
|
||||||
**/ios/**/*.moved-aside
|
|
||||||
**/ios/**/*.pbxuser
|
|
||||||
**/ios/**/*.perspectivev3
|
|
||||||
**/ios/**/*sync/
|
|
||||||
**/ios/**/.sconsign.dblite
|
|
||||||
**/ios/**/.tags*
|
|
||||||
**/ios/**/.vagrant/
|
|
||||||
**/ios/**/DerivedData/
|
|
||||||
**/ios/**/Icon?
|
|
||||||
**/ios/**/Pods/
|
|
||||||
**/ios/**/.symlinks/
|
|
||||||
**/ios/**/profile
|
|
||||||
**/ios/**/xcuserdata
|
|
||||||
**/ios/.generated/
|
|
||||||
**/ios/Flutter/App.framework
|
|
||||||
**/ios/Flutter/Flutter.framework
|
|
||||||
**/ios/Flutter/Generated.xcconfig
|
|
||||||
**/ios/Flutter/app.flx
|
|
||||||
**/ios/Flutter/app.zip
|
|
||||||
**/ios/Flutter/flutter_assets/
|
|
||||||
**/ios/Flutter/flutter_export_environment.sh
|
|
||||||
**/ios/ServiceDefinitions.json
|
|
||||||
**/ios/Runner/GeneratedPluginRegistrant.*
|
|
||||||
|
|
||||||
# Coverage
|
|
||||||
coverage/
|
|
||||||
|
|
||||||
# Exceptions to above rules.
|
|
||||||
!**/ios/**/default.mode1v3
|
|
||||||
!**/ios/**/default.mode2v3
|
|
||||||
!**/ios/**/default.pbxuser
|
|
||||||
!**/ios/**/default.perspectivev3
|
|
||||||
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
|
|
|
@ -24,37 +24,33 @@ class UnityWidgetController {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<bool> isReady() async {
|
/// Returns true if Unity is ready and false otherwise.
|
||||||
final bool isReady = await channel.invokeMethod('isReady');
|
Future<bool> isReady() => channel.invokeMethod('isReady');
|
||||||
return isReady;
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<bool> createUnity() async {
|
/// Returns true once Unity is ready.
|
||||||
final bool isReady = await channel.invokeMethod('createUnity');
|
Future<bool> createUnity() => channel.invokeMethod('createUnity');
|
||||||
return isReady;
|
|
||||||
}
|
|
||||||
|
|
||||||
postMessage(String gameObject, methodName, message) {
|
Future<bool> postMessage(String gameObject, methodName, message) => channel.invokeMethod('postMessage', <String, dynamic>{
|
||||||
channel.invokeMethod('postMessage', <String, dynamic>{
|
|
||||||
'gameObject': gameObject,
|
'gameObject': gameObject,
|
||||||
'methodName': methodName,
|
'methodName': methodName,
|
||||||
'message': message,
|
'message': message,
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
pause() async {
|
/// Unless an error is thrown, always returns true.
|
||||||
|
Future<bool> pause() {
|
||||||
print('Pressed paused');
|
print('Pressed paused');
|
||||||
await channel.invokeMethod('pause');
|
return channel.invokeMethod('pause');
|
||||||
}
|
}
|
||||||
|
|
||||||
resume() async {
|
/// Unless an error is thrown, always returns true.
|
||||||
await channel.invokeMethod('resume');
|
Future<bool> resume() => channel.invokeMethod('resume');
|
||||||
}
|
|
||||||
|
|
||||||
|
/// Called from [UnityWidget.dispose]
|
||||||
Future<void> _dispose() async {
|
Future<void> _dispose() async {
|
||||||
await channel.invokeMethod('dispose');
|
// await channel.invokeMethod('dispose');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Handles a method call from Android (on behalf of Unity) to Flutter.
|
||||||
Future<dynamic> _handleMethod(MethodCall call) async {
|
Future<dynamic> _handleMethod(MethodCall call) async {
|
||||||
switch (call.method) {
|
switch (call.method) {
|
||||||
case "onUnityMessage":
|
case "onUnityMessage":
|
||||||
|
@ -136,11 +132,13 @@ class _UnityWidgetState extends State<UnityWidget> {
|
||||||
|
|
||||||
void _onPlatformViewCreated(int id) {
|
void _onPlatformViewCreated(int id) {
|
||||||
_controller = UnityWidgetController.init(id, this);
|
_controller = UnityWidgetController.init(id, this);
|
||||||
|
|
||||||
|
print('--------------------------------------------');
|
||||||
|
print('| Internal setup complete ');
|
||||||
|
print('--------------------------------------------');
|
||||||
|
|
||||||
if (widget.onUnityViewCreated != null) {
|
if (widget.onUnityViewCreated != null) {
|
||||||
widget.onUnityViewCreated(_controller);
|
widget.onUnityViewCreated(_controller);
|
||||||
}
|
}
|
||||||
print('********************************************');
|
|
||||||
print('Controller setup complete');
|
|
||||||
print('********************************************');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue