Exemplo n.º 1
0
 public void BindToClient(NetworkClient client)
 {
     client.RegisterHandler(MsgTypeExt.STATE_UPDATE, HandleStateUpdate);
     //perform custom ownership system (client)
     client.RegisterHandler(MsgTypeExt.OWNERSHIP, (msg) => {
         //-1 means local client "ownership"
         Ownerships.RegisterOwnership(-1, ClientScene.FindLocalObject(new NetworkInstanceId(msg.ReadMessage <UintMsgBase>().val)));
     });
     this.client = client;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Spawns a GameObject on all clients and registers its ownership
 /// /// </summary>
 /// <param name="ownerId">The owner connection id</param>
 /// <param name="obj">The object to spawn and register</param>
 public void Spawn(int ownerId, GameObject obj)
 {
     NetworkServer.Spawn(obj);
     Ownerships.RegisterOwnership(ownerId, obj);
     NetworkServer.connections[ownerId].SendByChannel(MsgTypeExt.OWNERSHIP, new UintMsgBase(obj.GetComponent <NetworkIdentity>().netId.Value), Channels.DefaultReliable);
 }