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
|
||||
**/doc/api/
|
||||
.dart_tool/
|
||||
.flutter-plugins
|
||||
.packages
|
||||
.pub-cache/
|
||||
.pub/
|
||||
build/
|
||||
**/.dart_tool/
|
||||
**/.flutter-plugins
|
||||
**/.packages
|
||||
**/.pub-cache/
|
||||
**/.pub/
|
||||
**/build/
|
||||
|
||||
android/UnityExport/
|
||||
**/android/UnityExport/
|
||||
**/ios/UnityExport/
|
||||
|
||||
#example/
|
||||
example/unity/DemoApp/Builds/
|
||||
example/unity/DemoApp/Library/
|
||||
example/unity/DemoApp/Logs/
|
||||
example/unity/DemoApp/Temp/
|
||||
example/unity/DemoApp/.vs
|
||||
example/coverage/
|
||||
|
||||
# Android related
|
||||
**/android/**/gradle-wrapper.jar
|
||||
|
@ -49,6 +52,9 @@ example/unity/DemoApp/Temp/
|
|||
**/android/local.properties
|
||||
**/android/**/GeneratedPluginRegistrant.java
|
||||
|
||||
**/android/key.properties
|
||||
*.jks
|
||||
|
||||
# iOS/XCode related
|
||||
**/ios/**/*.mode1v3
|
||||
**/ios/**/*.mode2v3
|
||||
|
@ -74,6 +80,7 @@ example/unity/DemoApp/Temp/
|
|||
**/ios/Flutter/flutter_assets/
|
||||
**/ios/ServiceDefinitions.json
|
||||
**/ios/Runner/GeneratedPluginRegistrant.*
|
||||
**/ios/Flutter/flutter_export_environment.sh
|
||||
|
||||
# Exceptions to above rules.
|
||||
!**/ios/**/default.mode1v3
|
||||
|
|
|
@ -89,7 +89,7 @@ public class FlutterUnityView implements PlatformView, MethodChannel.MethodCallH
|
|||
@Override
|
||||
public void dispose() {
|
||||
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 {
|
||||
final bool isReady = await channel.invokeMethod('isReady');
|
||||
return isReady;
|
||||
}
|
||||
/// Returns true if Unity is ready and false otherwise.
|
||||
Future<bool> isReady() => channel.invokeMethod('isReady');
|
||||
|
||||
Future<bool> createUnity() async {
|
||||
final bool isReady = await channel.invokeMethod('createUnity');
|
||||
return isReady;
|
||||
}
|
||||
/// Returns true once Unity is ready.
|
||||
Future<bool> createUnity() => channel.invokeMethod('createUnity');
|
||||
|
||||
postMessage(String gameObject, methodName, message) {
|
||||
channel.invokeMethod('postMessage', <String, dynamic>{
|
||||
Future<bool> postMessage(String gameObject, methodName, message) => channel.invokeMethod('postMessage', <String, dynamic>{
|
||||
'gameObject': gameObject,
|
||||
'methodName': methodName,
|
||||
'message': message,
|
||||
});
|
||||
}
|
||||
|
||||
pause() async {
|
||||
/// Unless an error is thrown, always returns true.
|
||||
Future<bool> pause() {
|
||||
print('Pressed paused');
|
||||
await channel.invokeMethod('pause');
|
||||
return channel.invokeMethod('pause');
|
||||
}
|
||||
|
||||
resume() async {
|
||||
await channel.invokeMethod('resume');
|
||||
}
|
||||
/// Unless an error is thrown, always returns true.
|
||||
Future<bool> resume() => channel.invokeMethod('resume');
|
||||
|
||||
/// Called from [UnityWidget.dispose]
|
||||
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 {
|
||||
switch (call.method) {
|
||||
case "onUnityMessage":
|
||||
|
@ -136,11 +132,13 @@ class _UnityWidgetState extends State<UnityWidget> {
|
|||
|
||||
void _onPlatformViewCreated(int id) {
|
||||
_controller = UnityWidgetController.init(id, this);
|
||||
|
||||
print('--------------------------------------------');
|
||||
print('| Internal setup complete ');
|
||||
print('--------------------------------------------');
|
||||
|
||||
if (widget.onUnityViewCreated != null) {
|
||||
widget.onUnityViewCreated(_controller);
|
||||
}
|
||||
print('********************************************');
|
||||
print('Controller setup complete');
|
||||
print('********************************************');
|
||||
}
|
||||
}
|
||||
|
|
Reference in New Issue