Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kirya355 opened this issue May 26, 2020 · 1 comment
Closed

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

kirya355 opened this issue May 26, 2020 · 1 comment

Comments

@kirya355
Copy link

kirya355 commented May 26, 2020

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.

  1. Export unity project for android

  2. 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")

  1. I tried to add the unity-classes.jar as a library
    screen_86

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

  1. I tried to add the unity-classes.jar as a module
    screen_88

  2. Accepted this
    screen_89

  3. Module added in the main directory so I moved it in Android directory
    screen_90
    screen_91

  4. 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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants