You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I really need help because I have been about 7 days trying to make this works, but is not possible.
This is the scenario:
1.- I have one scene in unity with a simple button. This button try to emulate that I want to close the Unity View on Flutter.
2.-On Unity, I have a Floatting Action Button. This button try to emulate that I want to reload te Unity view Again.
So, I launch the App, the scene is loaded. I click the Unity button, and the Unity View disapears. Ok. And then, if I click the Flutter button, I want the Unity View appear again. But this doesn´t work. THe Unity View appear but frozen. Not working any more.
I need to understand what is the way to deal with this situations. I want to unload Unity view, navigate from Flutter to another view, and then, when the user pop to the first view, launch again Unity View... but is not possible.
This is my approach. I have to say, that this code, works as expected on iOS.
The idea for me was works with a Provider. I use a flag to know if Unity View is loaded or not.
This is the provider:
class UnityViewController extends ChangeNotifier {
bool _unityLoaded = true;
bool get unityLoaded => this._unityLoaded;
set unityLoaded(bool state) {
_unityLoaded = state;
notifyListeners();
}
}
In Unity, when the user click the button to unload, I figure out that on iOS I can use Application.Unload(), but looks that this don´t work on Android. So I use on that script a pre compiler flag just fon send this command to iOS. So, from Unity i have this script added to a button:
When the user click the button, the message unloadnow is send.
In Flutter, what I´m doing is catch this message, and call controller.unload() and then change the state of the view with de provider. Something like this:
So, I build again all this widget, and if the flag is true, I build again the UnityViewWidget, and if not, I only paint a container.
And in the scaffold I have a button for change again the state:
But this doesn´t work. On iOS works perfectly, the only difference is that I calling the unload method from Unity and not from Flutter.
Maybe there are another way to archive this?. I do not understand the way to load and unload the unity view... thanks in advance!
The text was updated successfully, but these errors were encountered:
I really need help because I have been about 7 days trying to make this works, but is not possible.
This is the scenario:
1.- I have one scene in unity with a simple button. This button try to emulate that I want to close the Unity View on Flutter.
2.-On Unity, I have a Floatting Action Button. This button try to emulate that I want to reload te Unity view Again.
So, I launch the App, the scene is loaded. I click the Unity button, and the Unity View disapears. Ok. And then, if I click the Flutter button, I want the Unity View appear again. But this doesn´t work. THe Unity View appear but frozen. Not working any more.
I need to understand what is the way to deal with this situations. I want to unload Unity view, navigate from Flutter to another view, and then, when the user pop to the first view, launch again Unity View... but is not possible.
This is my approach. I have to say, that this code, works as expected on iOS.
The idea for me was works with a Provider. I use a flag to know if Unity View is loaded or not.
This is the provider:
In Unity, when the user click the button to unload, I figure out that on iOS I can use Application.Unload(), but looks that this don´t work on Android. So I use on that script a pre compiler flag just fon send this command to iOS. So, from Unity i have this script added to a button:
When the user click the button, the message unloadnow is send.
In Flutter, what I´m doing is catch this message, and call controller.unload() and then change the state of the view with de provider. Something like this:
And of course, when the state is updated, I have this :
So, I build again all this widget, and if the flag is true, I build again the UnityViewWidget, and if not, I only paint a container.
And in the scaffold I have a button for change again the state:
But this doesn´t work. On iOS works perfectly, the only difference is that I calling the unload method from Unity and not from Flutter.
Maybe there are another way to archive this?. I do not understand the way to load and unload the unity view... thanks in advance!
The text was updated successfully, but these errors were encountered: