- Unity中实现画面传输首先要保证在同一个局域网下,其次,用到的FMETP STREAM插件进行画面传输的时候不分Server端和Client端,下面我们看一个案例
- 用大屏和小屏举例,我们要实时把小屏内容传输到大屏上,首先建两个空物体Server和Game,分别挂上FM Network Manager.cs和Game View Encoder.cs,然后进行配置
- 接下来我们给大屏建两个空物体Client和Game,分别挂上FM Network Manager.cs和Game View Decoder.cs,然后进行配置
- 在这里我们可以指定自己传输的画面到某一台设备上,我们需要在Client上的FM Network Manager.cs脚本中进行配置
找到 Init() 方法进行如下修改,即可实现指定设备的画面传输
void Init()
{
if (NetworkType == FMNetworkType.Server)
{
Server = this.gameObject.AddComponent<FMServer>();
Server.Manager = this;
Server.ServerListenPort = ServerSettings.ServerListenPort;
Server.ClientListenPort = ClientSettings.ClientListenPort;
Server.UseAsyncListener = ServerSettings.UseAsyncListener;
Server.UseMainThreadSender = ServerSettings.UseMainThreadSender;
}
else
{
Client = this.gameObject.AddComponent<FMClient>();
Client.Manager = this;
Client.ServerListenPort = ServerSettings.ServerListenPort;
Client.ClientListenPort = ClientSettings.ClientListenPort;
Client.UseMainThreadSender = ClientSettings.UseMainThreadSender;
Client.AutoNetworkDiscovery = ClientSettings.AutoNetworkDiscovery;
if (ClientSettings.ServerIP == "") ClientSettings.ServerIP = XMLData.Read()[1];
if (!Client.AutoNetworkDiscovery) Client.ServerIP = ClientSettings.ServerIP;
NetworkTransform = new FMNetworkTransform[NetworkObjects.Length];
for (int i = 0; i < NetworkTransform.Length; i++)
{
NetworkTransform[i] = new FMNetworkTransform();
NetworkTransform[i].position = Vector3.zero;
NetworkTransform[i].rotation = Quaternion.identity;
NetworkTransform[i].localScale = new Vector3(1f, 1f, 1f);
}
}
Initialised = true;
}
以上就是本次案例实现的画面传输的全部内容文章来源地址https://www.toymoban.com/news/detail-521007.html
文章来源:https://www.toymoban.com/news/detail-521007.html
到了这里,关于Unity的画面高质量传输( FMETP STREAM 实时画面传输案例)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!