質問編集履歴
2
参考ページの追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -15,4 +15,26 @@
|
|
15
15
|
Android用にビルドしたUnityからAndroidのネイティブプラグインを実行し、
|
16
16
|
メインのActivityにIntentしたService上のMessageListenerインスタンスに文字列を送りたいのですが、
|
17
17
|
|
18
|
-
ネイティブプラグインからService上のインスタンスへアクセスする方法が分からず困っています。ご教授いただけると幸いです。
|
18
|
+
ネイティブプラグインからService上のインスタンスへアクセスする方法が分からず困っています。ご教授いただけると幸いです。
|
19
|
+
|
20
|
+
# 追記
|
21
|
+
|
22
|
+
Androidプラグイン上のクラスをインスタンス化して、現在のActivityのFragmentManagerに追加しているコードを見つけたのですが、この繋がりを経由してプラグイン→Activityへの文字列の送信は可能でしょうか。
|
23
|
+
|
24
|
+
|
25
|
+
```Java
|
26
|
+
package com.eppz.plugins;
|
27
|
+
public class EPPZ_Alert extends Fragment
|
28
|
+
{
|
29
|
+
public static EPPZ_Alert instance; // Singleton instance
|
30
|
+
public static void start()
|
31
|
+
{
|
32
|
+
// Instantiate Fragment.
|
33
|
+
instance = new EPPZ_Alert_Fragment();
|
34
|
+
// Add to the current 'Activity' (a static reference is stored in 'UnityPlayer').
|
35
|
+
UnityPlayer.currentActivity.getFragmentManager().beginTransaction().add(instance, "EPPZ_Alert").commit();
|
36
|
+
}
|
37
|
+
...
|
38
|
+
}
|
39
|
+
```
|
40
|
+
参照元:http://eppz.eu/blog/unity-android-plugin-tutorial-1/
|
1
書式の改善
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,5 +1,18 @@
|
|
1
|
+
# 前提
|
2
|
+
|
3
|
+
「Android用にビルドしたUnity」 - 「AndroidNative」 - 「RaspberryPi(Node.js)」 3点間のデータ送受信についての質問です。
|
4
|
+
|
5
|
+
前提ですが、
|
6
|
+
Androidがスリープ状態であっても、AndroidNative - RaspberryPi間の通信が出来るように、
|
7
|
+
メインのActivity上でServiceクラスをstartServiceし、
|
8
|
+
そのServiceクラス上に、RaspberryPiとの通信を行うMessageListenerクラスを実装しています。
|
9
|
+
|
10
|
+
また、Unity - AndroidNative間の通信には、
|
11
|
+
AndroidNative上の「UnityPlayer.UnitySendMessage」関数と、Unity上の「Androidのネイティブプラグイン」を用いる予定です。
|
12
|
+
|
13
|
+
# 質問
|
14
|
+
|
1
15
|
Android用にビルドしたUnityからAndroidのネイティブプラグインを実行し、
|
2
|
-
メインのActivityにIntentしたService上のインスタンスに文字列を送りたいのですが、
|
16
|
+
メインのActivityにIntentしたService上のMessageListenerインスタンスに文字列を送りたいのですが、
|
3
17
|
|
4
|
-
ネイティブプラグインからService上のインスタンスへアクセスする方法が分からず困っています。
|
18
|
+
ネイティブプラグインからService上のインスタンスへアクセスする方法が分からず困っています。ご教授いただけると幸いです。
|
5
|
-
ご教授いただけると幸いです。
|