代码拉取完成,页面将自动刷新
同步操作将从 liyonghelpme/rongYaoDaLuCode 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
using System;
using UnityEngine;
public class UnityNetworkExample : MonoBehaviour
{
private int listenPort = 0x61a8;
public GameObject PlayerObject;
private string remoteIP = "127.0.0.1";
private int remotePort = 0x61a8;
private void OnConnectedToServer()
{
Network.Instantiate(this.PlayerObject, (Vector3) (UnityEngine.Random.insideUnitSphere * 5f), Quaternion.identity, 0);
}
private void OnGUI()
{
if (Network.peerType == NetworkPeerType.Disconnected)
{
if (GUI.Button(new Rect(10f, 10f, 100f, 30f), "Connect"))
{
Network.Connect(this.remoteIP, this.remotePort);
}
if (GUI.Button(new Rect(10f, 50f, 100f, 30f), "Start Server"))
{
Network.InitializeServer(0x20, this.listenPort, true);
}
this.remoteIP = GUI.TextField(new Rect(120f, 10f, 100f, 20f), this.remoteIP);
this.remotePort = int.Parse(GUI.TextField(new Rect(230f, 10f, 40f, 20f), this.remotePort.ToString()));
}
else
{
if (GUI.Button(new Rect(10f, 10f, 100f, 50f), "Disconnect"))
{
Network.Disconnect(200);
}
GUILayout.BeginArea(new Rect(10f, 60f, 200f, 500f));
int deviceID = 0;
foreach (string str in Microphone.devices)
{
GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(200f) };
if (GUILayout.Button(str, options))
{
USpeaker.SetInputDevice(deviceID);
}
deviceID++;
}
GUILayout.EndArea();
}
}
private void OnServerInitialized()
{
Network.Instantiate(this.PlayerObject, (Vector3) (UnityEngine.Random.insideUnitSphere * 5f), Quaternion.identity, 0);
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。