diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a6b48c..59e27fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 0.1.6+8 + +* Breaking change for unityframework iOS + +## 0.1.6+7 + +* Breaking change for unityframework iOS + ## 0.1.6+6 * Breaking change for unityframework iOS diff --git a/README.md b/README.md index abe87e2..0726b06 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Flutter unity 3D widget for embedding unity in flutter. Now you can make awesome ```yaml dependencies: - flutter_unity_widget: ^0.1.6+5 + flutter_unity_widget: ^0.1.6+8 ``` Now inside your Dart code you can import it. @@ -84,6 +84,8 @@ Be sure you have at least one scene added to your build. **iOS Platform**: 1. This only works with Unity version >=2019.3 because uses Unity as a library! 2. Depending on where you want to test or run your app, (simulator or physical device), you should select the appropriate SDK on `Target SDK`. + 3. Add this to the flutter app Info.plist ```io.flutter.embedded_views_preview + ```

diff --git a/ios/Classes/UnityUtils.mm b/ios/Classes/UnityUtils.mm index ad365a2..8698df0 100644 --- a/ios/Classes/UnityUtils.mm +++ b/ios/Classes/UnityUtils.mm @@ -11,8 +11,10 @@ static const int constsection = 0; bool unity_inited = false; +// keep arg for unity init from non main int g_argc; char** g_argv; +NSDictionary* appLaunchOpts; void UnityInitTrampoline(); @@ -38,17 +40,7 @@ UnityFramework* UnityFrameworkLoad() NSBundle* bundle = [NSBundle bundleWithPath: bundlePath]; if ([bundle isLoaded] == false) [bundle load]; - UnityFramework* ufw = [bundle.principalClass getInstance]; - if (![ufw appController]) - { - // Initialize Unity for a first time - [ufw setExecuteHeader: &_mh_execute_header]; - - // Keep in sync with Data folder Target Membership setting - [ufw setDataBundleId: "com.unity3d.framework"]; - - } return ufw; } @@ -61,8 +53,10 @@ extern "C" void InitUnity() ufw = UnityFrameworkLoad(); - // [ufw setDataBundleId: "com.unity3d.framework"]; - // [ufw frameworkWarmup: g_argc argv: g_argv]; + [ufw setDataBundleId: "com.unity3d.framework"]; + [ufw frameworkWarmup: g_argc argv: g_argv]; + // [ufw setExecuteHeader: &_mh_execute_header]; + // [ufw runEmbeddedWithArgc: gArgc argv: gArgv appLaunchOpts: appLaunchOpts]; } extern "C" void UnityPostMessage(NSString* gameObject, NSString* methodName, NSString* message) diff --git a/pubspec.yaml b/pubspec.yaml index e645b4c..03ee9d3 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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: 0.1.6+6 +version: 0.1.6+8 #authors: # - Rex Raphael # - Thomas Stockx