-
Notifications
You must be signed in to change notification settings - Fork 531
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
Calling a function from flutter to unity3d #31
Comments
It should be added to the README that the iOS version currently does not support communication from Unity to Flutter (never did). Flutter to Unity works on both Android and iOS, Unity to Flutter is Android only for now. The easiest way to get your project to compile on iOS is to remove the UnityMessageManager.cs :'( |
@thomas-stockx thanks for clarifying, but for me it also didn't work to communicate from Flutter to Unity. I tested the demo that basically have one button to pause and to resume the game. But unfortunately that did not work. After that I followed the documentation and imported the needed files, but immediately it prompted an error saying: "PrecompiledAssemblyException: Multiple precompiled assemblies with the same name" about NewtonJson.dll. I then deleted the folders /Standalone and /Windows, and leaving the folder AOT untouched. I exported to Flutter again and it worked without any errors. After successfully exporting, I then tried to compile it in Xcode but it gives the compilation error: Thank you for your kind help. |
@bedirhandev The following steps from the documentation are just for Unity to Flutter communcation (and should not be followed for iOS, as it does not work for iOS):
I think you can resolve your issue by removing UnityMessageManager.cs, the JsonDotNet folder and link.xml. |
@thomas-stockx, ah, thanks! Ok that explains a lot. But in the demo you have one button for pausing and resuming the game. The buttons are not working somehow. The demo code in Flutter _unityWidgetController.pause(); is not working, because the game is not pausing itself. Do you know how I can fix this issue, do I have to include include custom code in Unity? Thank you for your help so far :) |
Apparently only postMessage has been implemented in the iOS version, which is used for sending message from Flutter to a Unity GameObject: |
I see could you give an example how to use the method postMessage, pseudo code would help. Thanks. |
@thomas-stockx could we replace the current example with the new one you did in the gif |
Or maybe I make a new one and an updated video tutorial |
Hi @bedirhandev, From your Flutter code, you can use postMessage as follows:
This will use Unity's message handling system to send a message to a GameObject in your scene, in this case a GameObject called "AR Session Origin", and it will execute a method called "SetVideoUrl", with a string as parameter. (If you want more parameters, I'd recommend using a JSON as string and parsing that in your Unity code.) To receive these method calls in Unity, you need to implement
|
Thanks @juicycleff and @thomas-stockx it now works I have tested it on a iOS device. The communication works from Flutter to Unity, but not the other way. Hopefully, this will be fixed in the near future, but for now I can continue. Thanks! |
Hi,
Can someone provide an explanation how you can achieve to communicate from flutter to unity3d and back. I have read the documentation and imported the needed files.
At first when I exported it from unity3d to flutter I got this error about NewtonJSON: PrecompiledAssemblyException: Multiple precompiled assemblies with the same name. I then removed the folders Windows and AOT because unity3d found multiple dll's.
After compiling I get the following errror:
Undefined symbols for architecture arm64:
"_onUnityMessage", referenced from:
I try to pause and play unity3d.
The text was updated successfully, but these errors were encountered: