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

Any chance of getting the communication from Unity to Flutter in iOS? #161

Closed
sinano1107 opened this issue Jun 18, 2020 · 13 comments
Closed

Comments

@sinano1107
Copy link

I really want to get messages from Unity in Flutter.
This package doesn't support it, but is there any possibility of supporting it in the future?

Do you have any alternatives?
Is it possible to implement, for example, writing to a local file from Unity and importing it from Flutter?

@SachinGanesh
Copy link

We had the same issue. We created a local web server in Flutter and shared messages through HTTP protocol. You can check the built app here: https://www.youtube.com/watch?v=A56gVrDAXbU

http_server: any
Future _startWebServer() async {
    runZoned(() async {
      server = await HttpServer.bind(
        InternetAddress.loopbackIPv4,
        11223,
      );
      await for (var request in server) {
        handleRequest(request);
      }
    }, onError: (e, stackTrace) => print('Oh noes! $e $stackTrace'));
  }

@olenirwing
Copy link

How did you verify it cannot work? We are trying to get it to work, but somehow the message that is received is always just the first one, just as described here: #107 (comment)

Is that the error that you are referring to?

@sinano1107
Copy link
Author

?
About not being able to receive messages from Unity in Flutter on iOS?
Here's #31 (comment) where the developer says it's not compatible with iOS.
I haven't tried this feature, so I don't know what errors actually occur, but so far it shouldn't have been fixed.

@sinano1107
Copy link
Author

We had the same issue. We created a local web server in Flutter and shared messages through HTTP protocol. You can check the built app here: https://www.youtube.com/watch?v=A56gVrDAXbU

http_server: any
Future _startWebServer() async {
    runZoned(() async {
      server = await HttpServer.bind(
        InternetAddress.loopbackIPv4,
        11223,
      );
      await for (var request in server) {
        handleRequest(request);
      }
    }, onError: (e, stackTrace) => print('Oh noes! $e $stackTrace'));
  }

Are you a genius?
I'll give it a try, thank you!

@sinano1107
Copy link
Author

@SachinGanesh
Show me an example of simple Unity code.
I'm not sure how it works...

@SachinGanesh
Copy link

@SachinGanesh
Show me an example of simple Unity code.
I'm not sure how it works...

Example code to send video URL back to Flutter app

private IEnumerator UploadPath(string path)
{
        UnityWebRequest www = UnityWebRequest.Post("http://127.0.0.1:11223/record/store", path);
        yield return www.SendWebRequest();

        if (www.isNetworkError || www.isHttpError)
        {
            Debug.Log(www.error);
        }
        else
        {
            Debug.Log("Video link upload complete!");
        }
        yield return null;
}

@sinano1107
Copy link
Author

@SachinGanesh
How did you receive the [path] data from Unity in Flutter?
I was able to receive the URI but that's the only part I don't understand.

@TarekMedhat
Copy link

I really want to get messages from Unity in Flutter.
This package doesn't support it, but is there any possibility of supporting it in the future?

Do you have any alternatives?
Is it possible to implement, for example, writing to a local file from Unity and importing it from Flutter?

This Package supports messages both ways from Unity to flutter and flutter to unity.
I am using it myself and works both on ios/android


Add UnityMessageManager Support
Copy UnityMessageManager.cs to your unity project.
Copy this folder JsonDotNet to your unity project.
Copy link.xml to your unity project.

Check their example https://github.com/juicycleff/flutter-unity-arkit-demo.
I'm using/copied Editor scripts, UnityMessageManager.cs, JsonDotNet, link.xml from this example.

@sinano1107
Copy link
Author

@TarekMedhat
That was it!
That was good. I'll give it a try.
But why don't they go into more detail in the Readme?

@sinano1107
Copy link
Author

@TarekMedhat
How do you use UnityMessageManager?
I was able to eliminate the error by pasting the code, but I don't know how to use it specifically.
When I looked for it, I couldn't find the part that sends the message to the example either...
Can you give me the specific code?

@sinano1107
Copy link
Author

An example was found in another repository.
That's all right.
They were both very helpful! Thank you!

@TarekMedhat
Copy link

An example was found in another repository.
That's all right.
They were both very helpful! Thank you!

You are welcome, Can you share the other example link that you found?

@sinano1107
Copy link
Author

sinano1107 commented Jun 20, 2020

I found a use case in line 32 of this code

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

4 participants