unity_player_widget 0.1.0+3 copy "unity_player_widget: ^0.1.0+3" to clipboard
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 #

  1. Add unity_player_widget plugin to your Flutter project.
  2. Create a 2019.3.* Unity project (or use existed).
  3. Download Editor folder and add it to your unity project.
  4. Create a folder named "unity" in the Flutter project.
  5. 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 #

  1. In Unity project go to File->Build settings
  2. Add at least 1 scene to the project
  3. 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
  1. Select UnityPlayerWidget->Export Android
  2. 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).


  1. Move all created packages into android folder.
  2. 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'] }
	}
}
  1. 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")
  1. 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).
  2. (VUFORIA ONLY) Add android:screenOrientation="fullSensor" as an activity attribute in android/app/src/main/AndroidManifest.xml file.

iOS #

  1. In Unity project go to File->Build settings
  2. Add at least 1 scene to the project
  3. 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
  1. Select UnityPlayerWidget->Export iOS.
  2. Open Runner.xcworkspace with Xcode and add ios/unityLibrary/Unity-iPhone.xcodeproj to "Runner".


  1. Add Data folder to the UnityFramework in the Target Membership section.


  1. Add UnityFramework to "Runner".


  1. Go to Runner/Info.plist and set io.flutter.embedded_views_preview -> YES
  2. (AR ONLY) Go to Runner/Info.plist and set Privacy - Camera Usage Description -> [Some description]
  3. (EasyAR ONLY) Go to Unity-iPhone -> UnityFramework and set Enable Bitcode -> NO
2
likes
40
pub points
0%
popularity

Publisher

unverified uploader

A plugin that allows you to embed a Unity project in Flutter.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on unity_player_widget