Hi. Is there any solution to call setState in OnUnityMessage when re-open unity?juicycleff/flutter-unity-view-widget#225 . Android works well but iOS fails.
I think it might be the LifeCycle issue. Unity never exit and other widget was rebuild when reopen the same page.
The following is what I did on simple_screen.dart:
bool isTouched=false
this.isTouched ? Text("Don't touch me!") : Text("Touch me please!"),
debugPrint("Mounted state: ${this.mounted.toString()}");
setState(() {
this.isTouched = !this.isTouched;
});
Here is the full code of simple_screen.dart
import 'package:flutter/material.dart';
import 'package:flutter_unity_widget/flutter_unity_widget.dart';
import 'package:flutter_unity_widget_example/utils/screen_utils.dart';
class SimpleScreen extends StatefulWidget {
@override
_SimpleScreenState createState() => _SimpleScreenState();
}
class _SimpleScreenState extends State<SimpleScreen> {
static final GlobalKey<ScaffoldState> _scaffoldKey =
GlobalKey<ScaffoldState>();
UnityWidgetController _unityWidgetController;
double _sliderValue = 0.0;
@override
void initState() {
super.initState();
}
@override
Widget build(BuildContext context) {
final ScreenArguments arguments =
ModalRoute.of(context).settings.arguments as ScreenArguments;
return Scaffold(
appBar: AppBar(
title:
this.isTouched ? Text("Don't touch me!") : Text("Touch me please!"),
),
body: Card(
margin: const EdgeInsets.all(8),
clipBehavior: Clip.antiAlias,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(20.0),
),
child: Stack(
children: [
UnityWidget(
onUnityViewCreated: onUnityCreated,
isARScene: arguments.enableAR,
onUnityMessage: onUnityMessage,
),
Positioned(
bottom: 20,
left: 20,
right: 20,
child: Card(
elevation: 10,
child: Column(
children: <Widget>[
Padding(
padding: const EdgeInsets.only(top: 20),
child: Text("Rotation speed:"),
),
Slider(
onChanged: (value) {
setState(() {
_sliderValue = value;
});
setRotationSpeed(value.toString());
},
value: _sliderValue,
min: 0,
max: 20,
),
],
),
),
),
],
)),
);
}
void setRotationSpeed(String speed) {
_unityWidgetController.postMessage(
'Cube',
'SetRotationSpeed',
speed,
);
}
bool isTouched = false;
void onUnityMessage(controller, message) {
debugPrint("Mounted state: ${this.mounted.toString()}");
setState(() {
this.isTouched = !this.isTouched;
});
debugPrint(
'Received message from unityffffff: ${message.toString()} ${this.isTouched.toString()}');
}
void setStateForTouch() {
setState(() {
this.isTouched = true;
});
}
// Callback that connects the created controller to the unity controller
void onUnityCreated(controller) async {
this._unityWidgetController = controller;
}
}
Can anyone help me to solve this problem?
hello, can anyone help me plz! i can't build my app for release with cause in when building the plugin, it tells me at "#include <UnityFramework/UnityFramework.h>" that the header-file is missing. this happens only when trying to build for release/archive but not when doing a debug-build. this tbh is pretty urgent, cause i need to get the app to the store for a client. i'm not the only one, as there are some github issues of people having the same issue! thanks in advance
@subjectdenied Hi Christian, did you figure out the solution for this issue?
Hello everyone!
I’m using Vuforia on Unity version 2020.1.14f1. AR project.
I didn’t understand the steps explained under Android and Vuforia in the README file.
Maybe I the problem can be solved with one of those steps.
Problem during building fixed in Build.cs as in:
https://github.com/juicycleff/flutter-unity-view-widget/issues/234#issuecomment-735307249
Changed the minSdkVersion from 16 to 24 for some errors.
Running Gradle task 'assembleDebug'...
[:arcore_client:] /Users/pietrolentini/.gradle/caches/transforms-2/files-2.1/a39d320a02bdc6c4cca0585f10641eb4/arcore_client/AndroidManifest.xml:30:9-54 Error:
Missing 'package' key attribute on element package at [:arcore_client:] AndroidManifest.xml:30:9-54
[:arcore_client:] /Users/pietrolentini/.gradle/caches/transforms-2/files-2.1/a39d320a02bdc6c4cca0585f10641eb4/arcore_client/AndroidManifest.xml Error:
Validation failed, exiting
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed with multiple errors, see logs
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
Exception: Gradle task assembleDebug failed with exit code 1
I tried also to change the Gradle version but it still have some problems so I decided to step back to this position.
Also, is someone also experiencing this? juicycleff/flutter-unity-view-widget#281
Have you tried unloading the scene after you're done Cristian?
hi guys , how to solve this error , i've stuck in 1 week.
(*) - details omitted (listed previously)
Also, is someone also experiencing this? juicycleff/flutter-unity-view-widget#281
Hello Cristian, same issue here .. I tried to use unload in dispose, but when I try to go back to my screen where there is my unity, I am not able to launch it
Were you able to have the correct behavior ?