Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[Free][Released] GPM Communicator - communication between Unity and Native

Discussion in 'Assets and Asset Store' started by NHNCorporation, Apr 8, 2021.

  1. NHNCorporation

    NHNCorporation

    Joined:
    Mar 20, 2018
    Posts:
    12
    What is Communicator
    Communicator is a module that provides unified interface when sending data from/to Native.

    By unifying the entry point, it reduces the amount of used resources and overlapping codes, and makes data communication with Native much easier.

    Provided for free.

    Asset Store | Document

    You can install this using Game Package Manager. See the following steps for installation.

    Features
    Allows communication with Native through the unified interface.
    • Sends and immediately receives synchronous messages.
    • Sends asynchronous messages and receives them through receiver.
    • Provided for free.
    • The entire source code is included.
    Standard structures that implement plugins and their weaknesses


    The structure of Communicator and its benefits


    Code
    Send a synchronous message
    Code (CSharp):
    1.  
    2. public void CallSync()
    3. {
    4.    GpmCommunicatorVO.Message message = new GpmCommunicatorVO.Message()
    5.    {
    6.        domain = "${DOMAIN}",
    7.        data = "USER_SYNC_DATA",
    8.        extra = "USER_SYNC_EXTRA"
    9.    };
    10.  
    11.    GpmCommunicatorVO.Message responseMessage = GpmCommunicator.CallSync(message);
    12.  
    13.    StringBuilder sb = new StringBuilder();
    14.    sb.AppendLine("CallSync Response");
    15.    sb.AppendLine("Domain : " + responseMessage.domain);
    16.    sb.AppendLine("Data : " + responseMessage.data);
    17.    sb.AppendLine("Extra : " + responseMessage.extra);
    18.  
    19.    Debug.Log(sb.ToString());
    20. }
    21.  
    Send an asynchronous message

    Code (CSharp):
    1.  
    2. public void CallAsync()
    3. {
    4.    GpmCommunicatorVO.Message message = new GpmCommunicatorVO.Message()
    5.    {
    6.        domain = "${DOMAIN}",
    7.        data = "USER_ASYNC_DATA",
    8.        extra = "USER_ASYNC_EXTRA"
    9.    };
    10.  
    11.    GpmCommunicator.CallAsync(message);
    12. }
    13.  
    14. public void AddReceiver()
    15. {
    16.    GpmCommunicator.AddReceiver("DOMAIN", OnReceiver);
    17. }
    18.  
    19. private void OnReceiver(GpmCommunicatorVO.Message message)
    20. {
    21.    StringBuilder sb = new StringBuilder();
    22.  
    23.    sb.AppendLine();
    24.    sb.AppendLine("OnReceiver");
    25.    sb.AppendLine("Domain" + message.domain);
    26.    sb.AppendLine("Data" + message.data);
    27.    sb.AppendLine("Extra" + message.extra);
    28.  
    29.    Debug.Log(sb.ToString());
    30. }
    31.  
    How to Install
    Asset Store | Document

    1. Go to Asset Store and install Game Package Manager.
    2. Select the following editor menus: Tools > GPM > Manager.
    3. Select and install Communicator from the service list.


    Contact us
    We sincerely hope that Game Package Manager becomes a great asset to your game development. The following assets are included:
    LogViewer that lets you easily test bugs on devices.
    Webview that lets you open your website in game.
    AssetManagement that lets you efficiently manage assets.
    If you want any other features or have an issue, you can register the issue or write us an email:

    Email : dl_gpm_help@nhn.com
    Issue registration: https://github.com/nhn/gpm.unity/issues

    Thank you.

    One more thing
    Try the easy and efficiency Gamebase.
    It is a game platform that supports game authentication, Purchase, Indicator, Maintenance, operation, and security.
    Overview : https://docs.toast.com/en/Game/Gamebase/en/Overview/
     
    YUIHam likes this.