unity_player_widget 0.1.0+3 unity_player_widget: ^0.1.0+3 copied to clipboard
A plugin that allows you to embed a Unity project in Flutter.
unity_player_widget #
A plugin that allows you to embed a Unity project in Flutter.
How to use #
In development, use an example for now.
How to install #
Preparation #
- Add unity_player_widget plugin to your Flutter project.
- Create a 2019.3.* Unity project (or use existed).
- Download Editor folder and add it to your unity project.
- Create a folder named "unity" in the Flutter project.
- Move created Unity project to "unity" folder.
Your flutter project folder should look like this:
-android
-ios
-lib
-test
-unity
└{Your Unity Project}
-pubspec.yml
-README.md
Android #
- In Unity project go to File->Build settings
- Add at least 1 scene to the project
- Go to android Player Settings
!!!settings may vary depending on which Unity packages you use!!!
Basic player settings:
Scripting Backend -> IL2CPP
ARMv7 -> TRUE
ARM64 -> TRUE
AR Foundation player settings:
Minimum API Level -> 24
Scripting Backend -> IL2CPP
ARMv7 -> TRUE
ARM64 -> TRUE
Vuforia player settings:
Scripting Backend -> IL2CPP
ARMv7 -> TRUE
ARM64 -> TRUE
EasyAR player settings:
Auto Graphics API -> FALSE
Graphics APIs -> OpenGLES2
Multithread Rendering -> FALSE
Scripting Backend -> IL2CPP
ARMv7 -> TRUE
ARM64 -> TRUE
- Select UnityPlayerWidget->Export Android
- In Flutter project go to android/unityLibrary/libs and create package for every aar or jar file in the folder. (If you use AndroidStudio, just right-click to your project, select New->Module->{Import .JAR/.AAR Package} and find aar or jar file in the libs folder).
- Move all created packages into android folder.
- Go to android/unityLibrary/build.gradle
- Remove this line:
// GENERATED BY UNITY. REMOVE THIS COMMENT TO PREVENT OVERWRITING WHEN EXPORTING AGAIN
- Replace all dependencies by implementation project(':[Name of created package]')
Your dependencies should look like this:
dependencies { implementation project(':package1') implementation project(':package2') implementation project(':package3') implementation project(':package4') }
- Add buildTypes to android section:
android { //**// buildTypes { profile { matchingFallbacks = ['debug', 'release'] } } }
- Go to android/settings.gradle
- Include all created packages (first line of the file) Your include section should look like this:
include ':app', ':package1', ':package2', ':package3', ':package4'
- Add this to the end of the file:
include ":unityLibrary" project(":unityLibrary").projectDir = file("./unityLibrary")
- minSdkVersion in android/app/build.gradle and android/unityLibrary/build.gradle must be equal (change minSdkVersion in android/app/build.gradle if they are not).
- (VUFORIA ONLY) Add android:screenOrientation="fullSensor" as an activity attribute in android/app/src/main/AndroidManifest.xml file.
iOS #
- In Unity project go to File->Build settings
- Add at least 1 scene to the project
- Go to iOS Player Settings
!!!settings may vary depending on which Unity packages you use!!!
Basic player settings:
Metal API Validation -> FALSE
AR Foundation player settings:
Metal API Validation -> FALSE
Target Minimum iOS version -> 11.0
Architecture -> ARM64
Vuforia player settings:
(not tested yet)
EasyAR player settings:
Auto Graphics API -> FALSE
Graphics APIs -> Metal, OpenGLES2
Metal API Validation -> FALSE
Architecture -> Universal
- Select UnityPlayerWidget->Export iOS.
- Open Runner.xcworkspace with Xcode and add ios/unityLibrary/Unity-iPhone.xcodeproj to "Runner".
- Add Data folder to the UnityFramework in the Target Membership section.
- Add UnityFramework to "Runner".
- Go to Runner/Info.plist and set io.flutter.embedded_views_preview -> YES
- (AR ONLY) Go to Runner/Info.plist and set Privacy - Camera Usage Description -> [Some description]
- (EasyAR ONLY) Go to Unity-iPhone -> UnityFramework and set Enable Bitcode -> NO