Hello everyone, I have tried more than 5 different solutions and none of them worked.
Here are the steps I did:
1) Added in pubspec.yaml
flutter_unity_widget: ^0.1.6+5
2) Created unity project in "unity" folder
3) Copied Build.cs and XCodePostBuild.cs to unity//Assets/Scripts/Editor/
Open your unity project in Unity Editor. Now you can export the Unity project with Flutter/Export Android (for Unity versions up to 2019.2), Flutter/Export Android (Unity 2019.3.*) (for Unity versions 2019.3 and up, which uses the new Unity as a Library export format), or Flutter/Export IOS menu.
4) Export unity project for android
5) Wrote a simple script
`import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_unity_widget/flutter_unity_widget.dart';
// Callback that connects the created controller to the unity controller
void onUnityCreated(controller) {
this._unityWidgetController = controller;
}
}
`
6)Added in android: settings.gradle include ':app', ':unity-classes' include ":UnityExport" project(":UnityExport").projectDir = file("./UnityExport")
7) I tried to add the unity-classes.jar as a library
Hello everyone, I have tried more than 5 different solutions and none of them worked.
Here are the steps I did:
1) Added in pubspec.yaml flutter_unity_widget: ^0.1.6+5 2) Created unity project in "unity" folder 3) Copied Build.cs and XCodePostBuild.cs to unity//Assets/Scripts/Editor/
Open your unity project in Unity Editor. Now you can export the Unity project with Flutter/Export Android (for Unity versions up to 2019.2), Flutter/Export Android (Unity 2019.3.*) (for Unity versions 2019.3 and up, which uses the new Unity as a Library export format), or Flutter/Export IOS menu.
4) Export unity project for android
5) Wrote a simple script `import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_unity_widget/flutter_unity_widget.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget { @override _MyAppState createState() => _MyAppState(); }
class _MyAppState extends State {
static final GlobalKey _scaffoldKey =
GlobalKey();
UnityWidgetController _unityWidgetController;
double _sliderValue = 0.0;
@override void initState() { super.initState(); }
@override Widget build(BuildContext context) { return MaterialApp( home: UnityDemoScreen(), ); } }
class UnityDemoScreen extends StatefulWidget { UnityDemoScreen({Key key}) : super(key: key);
@override _UnityDemoScreenState createState() => _UnityDemoScreenState(); }
class _UnityDemoScreenState extends State {
static final GlobalKey _scaffoldKey =
GlobalKey();
UnityWidgetController _unityWidgetController;
Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Test003'), ), key: _scaffoldKey, body: SafeArea( bottom: false, child: WillPopScope( // ignore: missing_return onWillPop: () {}, child: Container( color: Colors.yellow, child: UnityWidget( onUnityViewCreated: onUnityCreated, ), ), ), ), ); }
// Callback that connects the created controller to the unity controller void onUnityCreated(controller) { this._unityWidgetController = controller; } } `
6)Added in android: settings.gradle
include ':app', ':unity-classes' include ":UnityExport" project(":UnityExport").projectDir = file("./UnityExport")
7) I tried to add the unity-classes.jar as a library
But this didn't work log output idea.log
8) I tried to add the unity-classes.jar as a module 9) Accepted this
10) Module added in the main directory so I moved it in Android directory
11) But after this step, I can't build my app Button for the build isn't working
Before this step:
How to integrate Unity with flutter?