天天看點

Unity5.1 新的網絡引擎UNET(十五) Networking 引用--下10、Network Proximity Checker11、NetworkReader12、NetworkServer13、NetworkStartPosition14、NetworkTransform15、NetworkTransformVisualizer16、NetworkTransport17、NetworkWriter



孫廣東 2015.7.21

本節提供了與網絡系統一起使用的元件的詳細資訊。

10、Network Proximity Checker

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close Your name Your email Suggestion * Submit suggestion

Cancel

NetworkProximityChecker 是一個元件,它可以用來控制 網絡用戶端,基于網絡玩家 接近的對比度的對象。若要使用它,請将該元件放在一定範圍内可見的對象上。此類依賴于實體計算的可見性。

Properties

Property: Function:
visRange The range that the object should be visible in.
visUpdateInterval how often in seconds the object should check for players entering it’s visible range.
checkMethod Which type of physics to use for proximity checking.

Network Manager HUD NetworkReader

11、NetworkReader

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close Your name Your email Suggestion * Submit suggestion

Cancel

NetworkReader 是一個用于從位元組流中讀取對象的 UNET 進階别 API 類。此類在與 NetworkWriter 一起工作。NetworkReader 具有許多Unity類型特定的序列化功能。

12、NetworkServer

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close Your name Your email Suggestion * Submit suggestion

Cancel

NetworkServer 是一個 UNET 進階别 API 類,管理來自多個用戶端的連接配接。

Properties

Property: Function:
connections The set of active connections to remote clients.
localConnections The set of active connections to local clients.
handlers The set of registered message handler function.
objects The set of spawned objects with NetworkIdentities.
active True if the server is listening and running (static).
localActiveClient True if there is a local client in the same process; this server is a “Host”.
numChannels The number of configured NetworkTransport QoS channels.

13、NetworkStartPosition

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close Your name Your email Suggestion * Submit suggestion

Cancel

NetworkStartPosition 被NetworkManager 使用,當建立player對象時。NetworkStartPosition的位置 和 旋轉 用來放新建立的Player 對象。

14、NetworkTransform

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close Your name Your email Suggestion * Submit suggestion

Cancel

NetworkTransform 元件通過網絡同步movemen運動的遊戲對象。此元件考慮權威,是以 LocalPlayer 對象 (其中有地方當局) 同步他們的 position 從用戶端到伺服器,然後出去給其他客戶機。其他對象 (與伺服器授權機構) 同步他們從伺服器到用戶端的位置。

若要使用此元件,請将其添加到您想要同步運動的預制或遊戲的對象。該元件要求遊戲對象具有 NetworkIdentity。請注意,必須催生網絡的對象來同步。

Properties

Property: Function:
transformSyncMode Which synchronization method to use for position.
sendInterval How often in seconds the object sends updates.
syncRotationAxis Which axis to use for rotation.
rotationSyncCompression What kind of compession to use for rotation.
syncSpin Flag to sync angular velocity.
movementTheshold The threshold to not send position updates.
snapThreshold The threshold to “pop” instead of interpolate.
interpolateRotation Factor to control rotation interpolation.
interpolateMovement Factor to control movement interpolation.

Hints

• NetworkTransform的inspector有一個 NetworkSendRate 滑塊   。對于被建立後不需要更新 - 如子彈的對象,将此滑塊設定為零。

15、NetworkTransformVisualizer

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close Your name Your email Suggestion * Submit suggestion

Cancel

NetworkTransformVisualizer 是一個實用程式utility 元件,允許可視化的内嵌使用 NetworkTransform 元件的對象。

Properties

Property: Function:
VisualizerPrefab The prefab of an object to create to visualize the target position.

16、NetworkTransport

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close Your name Your email Suggestion * Submit suggestion

Cancel

NetworkTransport 是 UNET 低級别 API 接口。它是一個靜态的類。

17、NetworkWriter

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close Your name Your email Suggestion * Submit suggestion

Cancel

NetworkWriter 是一個 UNET 進階别 API 類,用于将對象寫入位元組流。此類在與 NetworkReader 一起工作。NetworkWriter 具有許多統一類型特定的序列化功能。

NetworWriter 與 MessageBase 類用于使包含序列化的網絡消息的位元組數組。

void SendMessage(short msgType, MessageBase msg, int channelId)
{
    // write the message to a local buffer
    NetworkWriter writer = new NetworkWriter();
    writer.StartMessage(msgType);
    msg.Serialize(writer);
    writer.FinishMessage();

    myClient.SendWriter(writer, channelId);
}
           

繼續閱讀