Starter project to build Android apps using Flutter & Unity with echoAR
Make sure you have an echoAR API key. If you don't have one yet, register for FREE at echoAR.
- Add a 3D model to the console.
- Create a new Unity project.
- Install the echoAR Unity SDK.
- Open the sample scence under
echoAR/Examples/sample.unity
. - Set the API key in the Inspector of the echoAR game object.
- Open the Build Settings window by clicking File > Build Settings....
- Select Android and click Switch Platform.
- Check Export Project
- Open the Player Settings window by clicking Player Settings...
- Configure the folowing:
- Other Settings > Rendering > Graphics APIs: OpenGLES3
- Other Settings > Configuration > Scripting Backends: IL2CPP
- Other Settings > Configuration > Target Architectures: โ ARMv7, โ ARM64
- Notice what is your Minimum API Level. You may need it later.
- Close the Player Settings window
- Click Add Open Scenes
- Click Export and save as unityExport
- Open the Build Settings window by clicking File > Build Settings....
- Select iOS and click Switch Platform.
- Click Add Open Scenes
- Click Export and save as unityProject
- Import the project dependecies by running
flutter pub get
from your terminal
- Copy your unityExport folder to
<your_flutter_project>/android/unityExport
- Run
flutter pub run flutter_unity:unity_export_transmogrify
in your terminal - Open
<your_flutter_project>/android/app/build.gradle
and make sure your project minSdkVersion equals to the one you defined for your Unity Project as Minimum API Level. - Open
<your_flutter_project>/android/build.gradle
and, insideallprojects { repositories {} }
, add the following:so it will look something like this:flatDir { dirs "${project(':unityExport').projectDir}/libs" }
allprojects { repositories { google() jcenter() flatDir { dirs "${project(':unityExport').projectDir}/libs" } } }
- Open
<your_flutter_project>/android/settings.gradle
and add the following at the end of the file:include ':unityExport'
- Copy your UnityProject folder to
<your_flutter_project>/iOS/UnityProject
- Open
<your_flutter_project>/iOS/Runner.xcworkspace
in Xcode - Go to File > Add Files to "Runner", and add
<your_flutter_project>/ios/UnityProject/Unity-iPhone.xcodeproj
- Select
Unity-iPhone/Data
, and, in the Inspectors pane, set the Target Membership to UnityFramework - Select
Unity-iPhone
, select PROJECT : Unity-iPhone, and, in the Build Settings tab, configure the following:- Build Options > Enable Bitcode: No
- Linking > Other Linker Flags: -Wl,-U,_FlutterUnityPluginOnMessage
- Select Runner, select TARGETS : Runner, and, in the General tab, configure the following:
- Frameworks, Libraries, and Embedded Content: UnityFramework.framework -> Embed & Sign
- Open
Runner/Runner/Info.plist
, and configure the following:
Key | Type | Value |
---|---|---|
io.flutter.embedded_views_preview | Boolean | YES |
- Open your
main.dart
file - Find and replace the value
<YOUR-PROJECT-KEY>
with your API key and uncomment the code line - Find and replace the value
<YOUR-ENTRY-ID>
with your model's entry ID and uncomment the code line - Save the file and run the project on an andorid phone
Refer to our documentation to learn more about how to use Unity and echoAR.
This project uses a third part library.
Feel free to reach out at [email protected] or join our support channel on Slack.