Skip to content

katsumasa/RemoteConnect

Repository files navigation

RemoteConnection

GitHub release (latest SemVer)

Connecting the Unity Editor and Unity Player.

概要

UnityEditorとUnityPlayerで簡単に通信を行う為のパッケージです。

動作環境

Unity2019.4LTS以降

インストール

using Git

git clone https://github.com/katsumasa/RemoteConnect.git

using Unity Package Manager

image

  1. Click the add button in the status bar.
  2. The options for adding packages appear.
  3. Select Add package from git URL from the add menu. A text box and an Add button appear.
  4. Enter https://github.com/katsumasa/RemoteConnect.git in the text box and click Add.

Click here for details.

使い方

  1. UTJ.RemoteConnect.Player を継承したClassをGameObjectにAddComponentします。 ※このGameObjectがUnityPlayerのActiveなSceneに存在する場合にのみUnityEditorとの通信が可能であることに注意して下さい。
  2. UTJ.RemoteConnect.Editor.RecmoteConnectEditorWindowを継承したClassを作成します。
  3. 上記で作成したUTJ.RemoteConnect.PlayerUTJ.RemoteConnect.Editor.RecmoteConnectEditorWindowを継承したClassにkMsgSendEditorToPlayerkMsgSendPlayerToEditorを設定し、データを受信した時の処理を作成しremoteMessageCBへ追加します。
  4. Development Buildにチェックを入れてビルドを行います。
  5. ビルドしたアプリケーションをデバイス上で実行します。
  6. Unity Editor上でUTJ.RemoteConnect.Editor.RecmoteConnectEditorWindowを開きます。
  7. 上記Window上でプルダウンメニューConnect Toから接続するデバイスを選択します。

スクリプトリファレンス

UTJ.RemoteConnect.Player

変数

説明
remoteMessageCB Editorからのメッセージを受信した時に実行されるデリゲート
kMsgSendEditorToPlayer EditorからPlayer用固有識別子
kMsgSendPlayerToEditor PlayerからEditor用固有識別子
isConnected Editor/Player間の接続が行われているか(read only)

関数

説明
SendRemoteMessage 任意のバイト配列をUnityEditorへ送信します

Sample

public class SamplePlayer : UTJ.RemoteConnect.Player
{
  protected override void OnEnable()
  {
    kMsgSendEditorToPlayer = new System.Guid("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
    kMsgSendPlayerToEditor = new System.Guid("yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy");
    remoteMessageCB = MessageReciveCB;
    base.OnEnable();
  }

   void MessageReciveCB(UTJ.RemoteConnect.Message remoteMessageBase)
   {
       // 何かメッセージを受信した時の処理
   }
}

UTJ.RemoteConnect.Editor.RecmoteConnectEditorWindow

変数

説明
remoteMessageCB Editorからのメッセージを受信した時に実行されるデリゲート
kMsgSendEditorToPlayer EditorからPlayer用固有識別子
kMsgSendPlayerToEditor PlayerからEditor用固有識別子
isConnected Editor/Player間の接続が行われているか(read only)

関数

説明
SendRemoteMessage 任意のバイト配列をUnityEditorへ送信します

Sample

public class Sample SampleEditorWindow : RemoteConnectEditorWindow
{
    [MenuItem("Window/Sample")]
    static void OpenWindow()
    {
        var window = (SampleEditorWindow)EditorWindow.GetWindow(typeof(SampleEditorWindow));        
    }

    protected override void OnEnable()
    {
        kMsgSendEditorToPlayer = new System.Guid("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
        kMsgSendPlayerToEditor = new System.Guid("yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy");
        remoteMessageCB = MessageReciveCB;
        base.OnEnable();
    }

    void MessageReciveCB(UTJ.RemoteConnect.Message remoteMessageBase)
    {
       // 何かメッセージを受信した時の処理
    }
}

その他

フィードバック・コメントお待ちしております。

以上

About

Connecting the Unity Editor and Unity Player.

Topics

Resources

License

MIT, Unknown licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE.meta

Stars

Watchers

Forks

Packages

No packages published

Languages