4.0 KiB
flutter_unity_widget
Flutter unity 3D widget for embedding unity in flutter. Add a Flutter widget to show unity. Works on Android, iOS in works.
Installation
First depend on the library by adding this to your packages pubspec.yaml
:
dependencies:
flutter_unity_widget: ^0.1.2
Now inside your Dart code you can import it.
import 'package:flutter_graphql/flutter_graphql.dart';
Requirements
Preview
How to use
Add Unity Project
- Create an unity project, Example: 'Cube'.
- Create a folder named
unity
in react native project folder. - Move unity project folder to
unity
folder.
Now your project files should look like this.
.
├── android
├── ios
├── lib
├── test
├── unity
│ └── <Your Unity Project> // Example: UnityDemo App
├── pubspec.yml
├── README.md
Configure Player Settings
-
First Open Unity Project.
-
Click Menu: File => Build Settings => Player Settings
-
Change
Product Name
to Name of the Xcode project, You can find it followios/${XcodeProjectName}.xcodeproj
. -
Change
Scripting Backend
to IL2CPP. -
Mark the following
Target Architectures
:- ARMv7 ✅
- ARM64 ✅
- x86 ✅
Other Settings find the Rendering part, uncheck the Auto Graphics API
and select only OpenGLES2
.
Add Unity Build Scripts and Export
Copy Build.cs
and XCodePostBuild.cs
to unity/<Your Unity Project>/Assets/Scripts/Editor/
Open your unity project in Unity Editor. Now you can export unity project with Flutter/Export Android
or Flutter/Export IOS
menu.
Android will export unity project to android/UnityExport
.
IOS will export unity project to ios/UnityExport
.
Add UnityMessageManager Support
Copy UnityMessageManager.cs
to your unity project.
Copy this folder JsonDotNet
to your unity project.
Copy link.xml
to your unity project.
Do not run in the simulator