juicycleff / flutter-unity-view-widget

Embeddable unity game engine view for Flutter. Advance demo here https://github.com/juicycleff/flutter-unity-arkit-demo
BSD 3-Clause "New" or "Revised" License
2.13k stars 515 forks source link

A problem occurred evaluating project ':flutter_unity_widget'. #150

Closed kirya355 closed 3 years ago

kirya355 commented 4 years ago

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 screen_86

But this didn't work screen_87 log output idea.log

8) I tried to add the unity-classes.jar as a module screen_88 9) Accepted this screen_89

10) Module added in the main directory so I moved it in Android directory screen_90 screen_91

11) But after this step, I can't build my app screen_92 Button for the build isn't working

Before this step: screen_93

How to integrate Unity with flutter?

Jairolaya12x commented 4 years ago

Are u using only unity without Vuforia or ARFoundation? Because this requires an additional setup.

49