Uh oh!
There was an error while loading. Please reload this page.
forked from guilmedev/flutter-unity
- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFlutterUnityPlugin.cs
More file actions
Latest commit
53 lines (46 loc) · 1.29 KB
/
Copy pathFlutterUnityPlugin.cs
File metadata and controls
53 lines (46 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
usingSystem.Runtime.InteropServices;
usingUnityEngine;
namespaceFlutterUnityPlugin
{
publicclassMessage
{
publicintid;
publicstringdata;
publicstaticMessageFromJson(stringjson)
{
returnJsonUtility.FromJson<Message>(json);
}
publicstringToJson()
{
returnJsonUtility.ToJson(this);
}
}
publicstaticclassMessages
{
publicstaticvoidSend(Messagemessage)
{
stringdata=message.ToJson();
if(Application.platform==RuntimePlatform.Android)
{
using(AndroidJavaClassFlutterUnityPluginClass=newAndroidJavaClass("com.glartek.flutter_unity.FlutterUnityPlugin"))
{
FlutterUnityPluginClass.CallStatic("onMessage",data);
}
}
else
{
#if UNITY_IOS
FlutterUnityPluginOnMessage(data);
#endif
}
}
publicstaticMessageReceive(stringdata)
{
returnMessage.FromJson(data);
}
#if UNITY_IOS
[DllImport("__Internal")]
privatestaticexternvoidFlutterUnityPluginOnMessage(stringdata);
#endif
}
}