(Unity 5.1 からは UNET の使用を推奨しています。下記の情報は旧ネットワークシステムのものです。)
ネットワークビューはネットワーク上でデータを共有するための主要コンポーネントです。二種類のネットワーク通信があり、状態同期( State Synchronization )とリモートプロシージャコール( Remote Procedure Calls )と呼ばれます。
ネットワークビューは特定のオブジェクトの変更を監視します。これらの変更はネットワーク上の他のすべてのクライアントに共有され、状態の変更が通知されていることを保証します。この概念が状態同期( state synchronization )と呼ばれ、詳細は 状態同期の詳細(旧)ページで確認ができます。
状態同期のオーバーヘッドの発生が望ましくない状況はいくつかあり、例えば、新しいオブジェクトの位置や再度生成されたプレイヤーの情報の送信がそれに当たります。このようなイベントは頻繁なものでないため、関連するオブジェクトの状態を同期する意味がありません。その代わり、リモートプロシージャコール( remote procedure call )を用いてクライアントやサーバーに操作を実行するように指示することができます。リモートプロシージャコールに関する詳細は RPC の詳細(旧) を確認ください。
ネットワークビューは NetworkViewID でネットワーク上識別され、これはネットワークマシン上でユニークにした識別子です。128 ビットの数字として表現されますが、ネットワークを経由する際、可能である場合は 16 ビットに自動圧縮されます。
クライアント側で受信したパケットは NetworkViewID で指定された特定のネットワークビューに適用する必要があります。Unity はこの識別子を使って正しいネットワークビューを見つけることができ、データを展開して、受信パケットの内容をネットワークビューの特定のオブジェクトに適用することができます。
Editor でのネットワークビューの詳細については ネットワークビュー を参照してください。
ネットワークオブジェクトを作成するために Network.Instantiate() を使用する場合は、ネットワークビューを手動で適切に割り当てることを心配する必要がありません。バックグラウンドで自動的に処理されます。
しかし各ネットワークビューの NetworkViewID の値は Network.AllocateViewID を使って手動でセットすることができます。スクリプティングリファレンスのドキュメントで RPC 関数を持つすべてのクライアントでオブジェクトをインスタンス化し、NetworkViewID を AllocateViewID で手動セットする例が示されています。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.