PC传输图片到Hololens

从 PC 端传输图片到 Hololens 显示。

在 Unity 中开发, PC 端的应用可以发布到其它平台,这里只在 unity 工程中运行了测试。

利用 HoloToolKit - Sharing 进行消息传输。


消息处理在 CustomMessages.cs 中定义

先注册发送图片消息的 ID: Img

public enum TestMessageID : byte
        {
            Img,
            Max
        }

定义发送图片的函数 SendImg(FileStream ImgFs)

这里的图片消息输入是文件流,图片转换为文件流的操作在后文发送方的脚本中。

 public void SendImg(FileStream ImgFs)
        {
            // If we are connected to a session, broadcast our head info
            if (serverConnection != null && serverConnection.IsConnected())
            {
                // Create an outgoing network message to contain all the info we want to send
                NetworkOutMessage msg = CreateMessage((byte)TestMessageID.Img);

            

你可能感兴趣的:(unity,Hololens,unity,HoloLens,socket,Image)