Write your first App

Now let's make an app step by step. Through it's simple, it can show you some core functionalities of MeshExpert.


  • Add an object in the scene and name it as App
  • Add a script on the object and name it as GettingStartedSample.cs
  • Copy and paste the following codes to the script.
using System.Collections;
using UnityEngine;
using DataMesh.AR.Network;
using DataMesh.AR;
using MEHoloClient.Entities;
using MEHoloClient.Proto;

public class GettingStartedSample : MonoBehaviour, IMessageHandler
    public GameObject cube;
    private CollaborationManager collaborationManager;

    void Start()

    private IEnumerator WaitForInit()
        MEHoloEntrance entrance = MEHoloEntrance.Instance;
        while (!entrance.HasInit)
            yield return null;

        collaborationManager = CollaborationManager.Instance;


        MsgEntry entry = new MsgEntry();
        entry.ShowId = "Test";
        GetTransformFloat(cube.transform, entry);

        ShowObject showObject = new ShowObject(entry);
        SceneObject roomData = new SceneObject();
        roomData.ShowObjectDic.Add(showObject.ShowId, showObject);

        collaborationManager.roomInitData = roomData;


    private void GetTransformFloat(Transform trans, MsgEntry entry)

        float[] rs = new float[6];

    public void DealMessage(SyncProto proto)
        Google.Protobuf.Collections.RepeatedField<MsgEntry> messages = proto.SyncMsg.MsgEntry;
        if (messages == null)

        for (int i = 0; i < messages.Count; i++)
            MsgEntry msg = messages[i];
            cube.transform.position = new Vector3(msg.Pr[0], msg.Pr[1], msg.Pr[2]);
            cube.transform.eulerAngles = new Vector3(msg.Pr[3], msg.Pr[4], msg.Pr[5]);

            Debug.Log("Receive Message! " + msg.Pr);

    void Update()
        if (collaborationManager != null)
            if (collaborationManager.enterRoomResult == EnterRoomResult.EnterRoomSuccess)
                MsgEntry entry = new MsgEntry();
                entry.OpType = MsgEntry.Types.OP_TYPE.Upd;
                entry.ShowId = "Test";
                GetTransformFloat(cube.transform, entry);

                SyncMsg msg = new SyncMsg();



The GettingStartedSample inherits DealMessage(SyncProto proto) method from IMessageHandler. This Method will be called when application recieve message from server.

Object Property

  • Click object App in the scene and check its Inspector Panel
  • Drag object Cube in the scene to property Cube on the Panel

Object Property Setting

Runtime Tests

  • Deploy the app to HoloLens (check out Microsoft Doc)
  • Check if the HoloLens and the machine on which MeshExpert has been installed are in the same LAN environment.
  • Ensure that MeshExpert Server is running.
  • Launch the app on HoloLens. You will see a cube in front of your eyes.
  • Launch the app in Unity and move or revolve the cube in Scene.


  • Check the cube in HoloLens and you will see the cube transforms in the same way as in Unity.