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

  • If any script classes inherits private RPC methods from another script, then those RPC methods in their base class must made either public or protected, otherwise uLink won't find them.
  • Unity Network can only send RPCs within the same MonoBehaviour. uLink doesn't have such a limitation, but as a result it wont allow multiple MonoBehaviours with the same RPC per NetworkView. If, for example, a NetworkView has two MonoBehaviours as RPC receivers and both have defined an RPC method named Jump, make sure that one of them changes the name of their RPC, otherwise it will be ambiguous. There is a new feature in uLink 1.1 that lets you restrict the sending of an RPC to just one type of Monobehaviour.
  • If there are code setting the viewID property of any NetworkView directly, please replace it with a call to the method NetworkView.SetViewID() or NetworkView.SetManualViewID(). Otherwise the owner role will be uLink.NetworkPlayer.server by default.
  • If there are code using NetworkPeerType.Connecting this has to be replaced because that type has been removed. uLink separates peer types and connection statuses in a more clean way. Take a look at the two properties uLink.Network.status and uLink.Network.peerType in the uLink API reference.
  • The message uLink_OnDisconnectedFromServer() will not be fired on the server when using uLink. If there are code using this message on the server side for handling situations when the server is disconnecting make sure the code instead uses the new uLink message uLink_OnServerUninitialized() instead.
  • The behaviour of Network.isClient and uLink.Network.isClient is slightly different. uLink returns true when the client in connecting state and connected state, Unity returns true only when connected. It is possible to get the exact same behaviour in uLink with this code snippet:
(uLink.Network.isClient && uLink.Network.status == uLink.NetworkStatus.Connected)