MIGRATE TO uLINK
MIGRATE TO uLINK
It is easy to migrate from Unity's built-in networking to uLink
networking. Install uLink, start the converter from the uLink
menu in the editor and convert the complete game in two steps.
If you want to read what the converter does or want to learn how
to do the migration manually read the rest of this chapter.
Game object and prefab changes
- Do not use the Unity NetworkView component in your
prefabs or game objects. Use the uLinkNetworkView script
component instead.
- If the game object is listed in the hierarchy view in the Unity
editor, a Manual View ID has to be given to the
uLinkNetworkView component. When the component is added,
choose a number starting from 1. Assign a unique number to every game
object. Game objects that are instantiated dynamically with
uLink.Network.Instantiate() will get a unique
viewID automatically during runtime.
- All prefabs that will be used in
uLink.Network.Instantiate() must be placed in the folder
"Assets/Resources". Do not place these prefabs in
subfolders. There is no limitation to the file location for prefabs
when using uLink.NetworkView.AssignManualViewID() or
uLink.NetworkView.Assign().
- Not mandatory, but recommended: All prefabs that will be used in
uLink.Network.Instantiate() should not have multiple
uLinkNetworkView components. Instead there is a special
script called uLinkObservedList that should be
used. Use this list as a container for all other components that needs
to be synchronized over the network. For example, if you want to sync
both the transform and the animation of an avatar, this is the way to
go. The prefab that is instantiated using
uLink.Network.Instantiate() should have one
uLinkNetworkView observing a
uLinkObservedList of length two, containing two
components; the transform and the animation script. More details about
this is covered in the Network Views chapter. The uLink converter does not do this
change, you have to do this refactoring manually.
General code changes
- Add the uLink namespace to all network related
classes, enums and structs. Two examples: Change from
NetworkPlayer to uLink.NetworkPlayer and change
from RPCMode.Server to uLink.RPCMode.Server.
- Add the uLink_ prefix to all network related messages
(events) like this: uLink_OnServerConnected(). For a
complete list of all network related messages available in
uLink, look at Appendix A.
- The usage of the keyword networkView should be
replaced with uLink.NetworkView.Get(this) in all
scripts. There are other way to replace it, documented in the end of
the Network Views chapter, but we recommend this particular replacement because it
works in all script languages and thus makes the migration work
easier.
Special code changes