M
M
MYTY
MYTY SDK
Search
K

Integrate with Flutter Project

Flutter Unity Widget

This is an open-source project that helps developers to easily integrate Flutter Project with Unity. It includes simple interface to send message to Unity, receive message from Unity, and embed Unity Widget as a component of Flutter Project

Configuration

Following steps are required to embed Unity inside your Flutter project
  1. 1.
    Open the ios/Runner.xcworkspace (workspace, not the project) file in Xcode, right-click on the Navigator (not on an item), go to Add Files to "Runner" and add the ios/UnityLibrary/Unity-Iphone.xcodeproj file.
Unity-iPhone added
  1. 2.
    Open the ios/Runner/AppDelegate.swift file and change the following:
import UIKit
import Flutter
+ import flutter_unity_widget
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
+ InitUnityIntegrationWithOptions(argc: CommandLine.argc, argv: CommandLine.unsafeArgv, launchOptions)
GeneratedPluginRegistrant.register(with: self)
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
  1. 3.
    Add the UnityFramework.framework file as a library to the Runner project
UnityFramework.framework added
Even with these configurations, there might be a problem launching the application. Please refer to the section below to resolve problems.
An example of Flutter-Unity integrated MYTY Avatar project can be found in the section below.